title: What's the best way to remove duplicate URI params from a string?
body: <p>I have a string, <code>root?param1=...&amp;param2=...&amp;param3=...</code>, and I want to create a java method that will remove any duplicate params.  The values will always be the same, but sometimes the params are duplicated as per the application's function (don't ask).  Therefor,</p>
  
  <pre><code>HTTP://root?param1=value&amp;param2=value2&amp;param2=value2param3=value3&amp;param3=value3&amp;param1=value&amp;param1=value
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>HTTP://root?param1=value&amp;param2=value2&amp;param3=value3
  </code></pre>
  
  <p>I've been out of programming too long to remember the best ways to do this but my original train of thought went something like this:</p>
  
  <p>Grab each param and stick into a temp array, run through temp array and compare if array[i] equals to any other param name.  If so, delete.  If not, add back to a return string.  At end of loop, print return string.</p>
  
  <p>But that would require O(n) for the length of the URI plus O(m)! for the size of the array (m being the number of params).  I think that would be pretty bad considering I'll be running this method around 5,000x per minute for all incoming URIs.  Is there a better way to go about this or an out-of-the-box java method that handles some of the overhead?</p>