title: Java URL encoding of query string parameters
body: <p>Say I have a URL </p>
  
  <pre><code>http://example.com/query?q=
  </code></pre>
  
  <p>and I have a query entered by the user such as:</p>
  
  <blockquote>
    <p>random word £500 bank $</p>
  </blockquote>
  
  <p>I want the result to be a properly encoded URL:</p>
  
  <pre><code>http://example.com/query?q=random%20word%20%A3500%20bank%20%24
  </code></pre>
  
  <p>What's the best way to achieve this? I tried <code>URLEncoder</code> and creating URI/URL objects but none of them come out quite right.</p>