Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Writing files across network

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to write a file from my local machine to a network path. Here is how I am doing it:



When I do this, I get a java.io.FileNotFoundException. I can browse to the directory just fine with Start ---> run ---> \\sweetums\users$...

What am I doing wrong?

Thanks for your help.

Tom
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tom Sullivan
When I do this, I get a java.io.FileNotFoundException. I can browse to the directory just fine with Start ---> run ---> \\sweetums\users$...

What am I doing wrong?



You need to access it by ftp protocol or by http by publishing the file on a web server. Simply providing machine name or accessing it by file:///... will not work.


- Naseem
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Naseem Khan:

You need to access it by ftp protocol or by http by publishing the file on a web server. Simply providing machine name or accessing it by file:///... will not work.



I don't think that is true. If I remember correctly, you can easily open a network file in a JFileChooser.

Anyway, moving to our IO forum...
 
Tom Sullivan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for posting in the wrong forum from the start. Oops. Anyway, thanks for the help. I don't understand why I can't just say: "u:\\mydir" or, as I have here, "\\\\sweetums\\...". Can someone show me an example of what I need to do?
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We do what you're talking about "u:\mydir", for example, but you need to map a drive somehow first. We do this in Windows as well as OS400. Once the drive is mapped you can access anything on that drive with normal IO works (as long as you're authorized to access the folders and files.
 
Tom Sullivan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Dan. The drive is mapped. I can browse it just fine from the same machine I'm running the test from (the drive is my personal drive on the network). Yet, the IO exception??? Could there be some other problem? I KNOW I have all the permissions I need.
 
Tom Sullivan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LOL. Just figured it out. Did not see a space in the string so I fixed that. Duh...
 
Dan Walin
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The good news is that I was able to take your example and just change the path to a server I use and it worked just fine. So, I'm thinking your code is fine and since you can find the fine in "run" then your connection is fine. I wonder if it's a simple typing mistake. I often have test files that I call test.txt and then accidentally code to look for text.txt or some similar mistake. I'd just double check the name of each directory and the file itself.
 
Dan Walin
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't see your reply before posting mine. Looks like a simple mistake which is my most common type.
 
reply
    Bookmark Topic Watch Topic
  • New Topic