title: Problem extracting port number with URL.getPort() when URL contains "]"
body: <p>I'm using java.net.URL.getPort() to extract the port number from a URL. Most of the time this works great. However, when the URL contains a right bracket character "]" it fails:</p>
  
  <pre><code>new URL("http://abc.com:123/abc.mp3").getPort();
   returns: (int) 123
  </code></pre>
  
  <p>But if the URL contains "]" I get:</p>
  
  <pre><code>new URL("http://abc.com:123/abc].mp3").getPort();
   returns: (int) -1
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>EDIT #1: As a test, I pasted this same code into a non-Android Java app and the port number was correctly returned, so this appears to be an anomaly with the Android SDK.</p>