简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM