Question

In java i created a virtual file system url string (as a String object). But when i convert this String into URL Object i got unknown protocol: vfs exception. My java code looks like follows


String urlString = "vfs:/E:/Servers/jboss7/standalone/deployments/isms.war/WEB-INF/lib/aribaweb.jar/META-INF/aribaweb.properties";
        URL url = new URL(urlString);

and the exception looks like follows


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)

Was it helpful?

Solution

Yes, like doing this. The URL is invalid when we convert the String to URL. So, I think we can do this, like follows:

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();

Like this. Don't show exception what you say.

Good luck

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top