Java: How to read content from redirected URLs?
<p>I use the following Java code in a Bean to read a URL's content:</p>

<pre><code>String url;
String inputLine;
StringBuilder srcCode=new StringBuilder();

public void setUrl (String value) {
    url = value; 
}

private void scanWebPage() throws IOException {
    try {
         URL dest = new URL(url);
         URLConnection yc =  dest.openConnection();
         yc.setUseCaches(false);
         BufferedReader in = new BufferedReader(new 
                        InputStreamReader(yc.getInputStream()));
         while ((inputLine = in.readLine()) != null)
            srcCode = srcCode.append (inputLine);
         in.close();
    } catch (FileNotFoundException fne) {
         srcCode.append("File Not Found") ;
    }
}
</code></pre>

<p>The code works fine for most URL's, but does not work for redirected URLs. How can I update the above code to read content from redirected URLs? For redirected URLs, I get <code>"File Not Found"</code>.</p>
