Question

I'm trying to create a folder to a mapped network drive Z: using Java

Unfortunately the file is not getting created. This is what I'm doing:

File file = new File("Z:/file1");
file.mkdir();

This code works when not using mapped network drive. This is on Windows environment.

Any ideas?

Was it helpful?

Solution

Ok I figured this out. Tomcat is running under Windows 2003 Server. According to what I found is that when Tomcat is started under the Windows Services, for some reason it doesn't have access to the mapped network drive. Using UNC paths worked for me.

File myFile = new File("\\\\server\\shared\\input");
myFile.mkdir();

I was able to create a folder on the mapped network drive on that server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top