URL url2 = file.toURI().toURL();
It does not handle special characters correctly 1 as per this bug.
Wouldn't it be easier to use
Why don't you just use the
createImage function that 1 takes a String filename instead?
I think the right answer to this question 5 is the one exposed in this link http://www.jguru.com/faq/view.jsp?EID=1280051
As exposed 4 in the link above, the right way to do this 3 is:
// Supposing f is the referenced file in code and we want to // get an URL instance without deprecation warnings. URL externalForm = f.toURI().toURL();
There is no catch for MalformedURLException 2 as the question is about deprecation of 1 the method file.toURL().
Hopes this helps.
You could consider using ImageIO as an alternative.
i think that you must write the url in this 2 way
C:/Documents and settings/Administrator/...
not 1 in this
C:\Documents and settings\Administrator...
More Related questions