• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Read a file from a mapped drive

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to read a file from a mapped drive using a servlet. I used the following code to map the drive:
try{
Runtime.getRuntime().exec("net use x: \\\\servername\\dir");
}
catch(IOException ioe) {
... set error
return;
}
which when I run this it doesn't throw an ioexception. But when I try to read a file using the following code:
File dir = new File("x:\\version.dat");
FileInputStream in = new FileInputStream(dir);
int c;
while ((c = in.read()) != -1)
inBuf.append((char)c);
in.close();

I get this error:
reported this exception: x:\version.dat (The system cannot find the path specified). Please report this to the administrator of the web server.
java.io.FileNotFoundException: x:\version.dat (The system cannot find the path specified) at java.io.FileInputStream.open(Native Method) ........
I even logged onto the server and mapped x: from the command prompt and then verified with dir that the file was there. Does anyone have any ideas on how to make this work or if I have the directory mapped correctly?
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have run into the same problem. Can anybody help?
 
Forget Steve. Look at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic