简体   繁体   English

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

[英]How to create a File representing a path on a Windows server without mapping a drive?

I tried this: 我试过这个:

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

but it threw: 但它扔了:

java.lang.IllegalArgumentException: URI has an authority component

使用Windows样式路径(带有前三个斜杠):

File file = new File("\\\\\\server\\e$\\somefile");

使用JCIFS ,使用smb://[[[domain;]username[:password]@]server[:port]/[[share]]风格的URL,或者有一天你会醒来,尝试运行你的应用程序来自不同的操作系统,并发现“一次编写,随处运行”的概念比你想象的更加热闹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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