GetURLsource method gives in some cases erros java
<p>I have developed this piece of code to get the url source code of a web page. Yet this method gives sometimes fails, and it is unable to 'grab' the source code of a page.</p>

<pre><code> private static String[] getUrlSource(String url) throws IOException {
    List&lt;String&gt; myList = new ArrayList&lt;String&gt;();
    URL site = new URL(url);
    BufferedReader in = new BufferedReader(new InputStreamReader(
                site.openStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null)
        myList.add(inputLine);
    in.close();

    String[] arr = myList.toArray(new String[myList.size()]);
    return arr;
}
</code></pre>