在java中,我创建了一个virtual file system
url字符串(作为String对象)。但当我将此字符串转换为URL Object
时,我得到了unknown protocol: vfs exception
。我的java代码如下所示
String urlString = "vfs:/E:/Servers/jboss7/standalone/deployments/isms.war/WEB-INF/lib/aribaweb.jar/META-INF/aribaweb.properties";
URL url = new URL(urlString);
,异常如下所示
Exception in thread "main" java.net.MalformedURLException: unknown protocol: vfs
at java.net.URL.(URL.java:574)
at java.net.URL.(URL.java:464)
at java.net.URL.(URL.java:413)
at RegExpression.main(RegExpression.java:15)
答案 0 :(得分:1)
是的,就像这样做。将String
转换为URL
时,网址无效。所以,我认为我们可以这样做,如下:
String urlString = "vfs:/E:/Servers/jboss7/standalone/deployments/isms.war/WEB-INF/lib/aribaweb.jar/META-INF/aribaweb.properties";
File file = new File(urlString);
URL url = file.toURI().toURL();
喜欢这个。不要表示你说的异常。
祝你好运