문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top