JDK-6459448 : Desktop.browse(URI) method does not handle escaping of reserved characters
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2006-08-11
  • Updated: 2010-04-02
  • Resolved: 2006-08-11
Related Reports
Duplicate :  
Relates :  
Description
This forum post demonstrates a problem launching the browser with a URI that includes escaped characters:
 http://forums.java.net/jive/thread.jspa?threadID=17375&tstart=0

The URI class is correct here and the issue appears to be that the browse method needs to use the raw path string or do any other necessary conversion for the browser.

Here is a copy of the forum post:


"can I use desktop.browse(uri) to open a browser window if the uri has escaped characters in (Eg spaces or '#') ???

File w = new File("C:\\Output DOC\\Default_CSH.htm#1");
URI uri = w.toURI();
desktop.browse(uri);

the toString() of the uri replaces ' ' with '%20' and replaces '#' with '%23'.
However the getPath() method returns the correct location.

But the browse option opens a browser at the address with the escaped characters in rather than the correct file path. Hence it cannot find the location and throws;

java.io.IOException:
Failed to open file:/C:/Output%20DOC/Default_CSH.htm%231

Is this a bug?
Are there any solutions?"