Create folder in a mapped network drive using Java
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?
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.
精彩评论