title: How to get the complete URL address most efficiently?
body: <p>I'm using a Java program to get expanded URLs from short URLs. Given a Java <code>URLConnection</code>, among the two approaches, which one is better to get the desired result?</p>
  
  <pre><code>Connection.getHeaderField("Location");
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>Connection.getURL();
  </code></pre>
  
  <p>I guess both of them give the same output. The first approach did not give me the best results, only 1 out of 7 were resolved. Can the efficiency be increased by the second approach?</p>
  
  <p>Can we use any other better approach?</p>