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
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact