Parsing of URL's which contain Windows Path separator

Shirish Kuncolienkar shirishk at linux.vnet.ibm.com
Thu Aug 9 01:53:20 PDT 2012


Hi,

I have the following piece of code

         URL url = new URL("file", "/", "C:\\temp\\Java6");
         System.out.println(url);
         URL url1 = new URL(url, "hello.html");
         System.out.println(url1);

first System out prints as "file:///C:\temp\Java6\Lotus"
Second one prints the value "file:////hello.html"

As mentioned by URL parser specification the windows path separator 
happens to be a special character and hence the whole path is considered 
as a single block.
However it will be useful for the URL class to take consider "\" 
character as a path separator as a special case and be able create 
relative url which is a valid one.

I see mozilla browser simply replaces the "\" by a "/" and continues. 
URL parser could follow a similar approach.

Any thoughts ?




More information about the net-dev mailing list