failed to open file file://D/:/dev/test_all.html JavaException: 开发者_StackOverflow社区java.net.UnknownHostException: D
Any ideas for why this happens?
the third / is in the wrong place, the file url is contructed with file:///<path>
Your URL is malformed. Instead of file://D/:/
you want file://D:/
-- no slash between the drive letter and the colon.
Here is my solution that's actually working with XMLParserv2, I hope this helps:
protected URL createURL(String filename){
URL url = null;
try {
url = new URL("file://" + System.getProperty("user.dir") + File.separator + filename);
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
return url;
}
精彩评论