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?
Sunetra Saha
Ranch Hand
Joined: Feb 25, 2001
Posts: 77
posted
0
I have run into the same problem. Can anybody help?