Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在不映射驱动器的情况下在Windows服务器上创建表示路径的文件?_Java_Windows_File_Remote Server - Fatal编程技术网

Java 如何在不映射驱动器的情况下在Windows服务器上创建表示路径的文件?

Java 如何在不映射驱动器的情况下在Windows服务器上创建表示路径的文件?,java,windows,file,remote-server,Java,Windows,File,Remote Server,我试过这个: URI uri = URI.create( "file://servername/e$/somefile" ); File file = new File(uri); 但它抛出: java.lang.IllegalArgumentException: URI has an authority component 使用Windows样式路径(带前导三个斜杠): 使用smb://[[domain;]username[:password]@]server[:port]/[[share

我试过这个:

URI uri = URI.create( "file://servername/e$/somefile" );
File file = new File(uri);
但它抛出:

java.lang.IllegalArgumentException: URI has an authority component
使用Windows样式路径(带前导三个斜杠):


使用
smb://[[domain;]username[:password]@]server[:port]/[[share]]
-风格的URL,或者有一天你会醒来,尝试从不同的操作系统运行你的应用程序,发现“写一次,在任何地方运行”的概念比你想象的还要有趣。

为什么是三重斜杠而不是两重斜杠?根据标题和标签,这个问题只有Windows上下文。我的代码不可能在其他操作系统上运行。
File file = new File("\\\\\\server\\e$\\somefile");