Reputation: 836
failed to open file file://D/:/dev/test_all.html JavaException: java.net.UnknownHostException: D
Any ideas for why this happens?
Upvotes: 6
Views: 20076
Reputation: 1033
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;
}
Upvotes: 1
Reputation: 6453
the third / is in the wrong place, the file url is contructed with file:///<path>
Upvotes: 28
Reputation: 8724
Your URL is malformed. Instead of file://D/:/
you want file://D:/
-- no slash between the drive letter and the colon.
Upvotes: 6