• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing files across network  RSS feed

 
Tom Sullivan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • 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
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Dan Walin
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!