title: How to avoid redundant double encoding in java.net.URI?
body: <p>I'm writing a convert from URL to URI, for Http method that only takes java.net.URI as parameter.</p>
  
  <p>My implementation is like this:</p>
  
  <pre><code>  new URI(url.getProtocol(), url.getAuthority(), url.getPath(), url.getQuery(), null);
  </code></pre>
  
  <p>So it won't break on URL that has space (under the excuse of Malformed URL). However, when encoding the following url:</p>
  
  <pre><code>http://www.****.ca/en-ca/Catalog/Gallery.aspx?ID=Mass%20Spectrometry%20[GC/MS%20and%20ICP-MS]&amp;PID=Gas%20Chromatography%20Mass%20Spectrometry%20Consumables
  </code></pre>
  
  <p>it transforms all %20 into %2520, which leads to invalid address.</p>
  
  <p>Is there a way in Java to correctly parse all kinds of URL? Including those with both %20 and spaces? Like a browser or wget command.</p>