title: URLConnection.getURL method
body: <p>I would like to have a second opinion on a small piece of Java code.</p>
  
  <p>Will the method below <strong>always</strong> return an output string equal to the input string?</p>
  
  <pre><code>private static String func(final String url)
  {
      HttpURLConnection con = (HttpURLConnection)new URL(url).openConnection();
      con.setInstanceFollowRedirects(true);
      ...
      ...
      return con.getURL().toString();
  }
  </code></pre>
  
  <p>The question refers to <strong>all</strong> possible scenarios, such as automatic redirection, etc.</p>