Why did the toURL() method of File get deprecated in Java 6? Should I stop using it now.

John Zukowski

The toURL() method of File does not properly escape characters that aren't valid in a URL. You can write better code today without waiting for Java 6 by calling the toURL() method after calling toURI() on a File object:

    URL url1 = file.toURL();         // bad
    URL url2 = file.toURI().toURL(); //good
About | Sitemap | Contact