Reading web contents, getting exception
<p>Im making an Android application, and for that i have to get JSON content from a URL (which is output by some python script).</p>

<p>I found a method for that on SO, but i can't get it to work. This is the code:</p>

<pre><code>public String webGet(String URL) throws Exception  
{ 
    BufferedReader in = null; 
    try  
    { 
        HttpClient client = new DefaultHttpClient(); 
        client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "android"); 

        HttpGet request = new HttpGet();
        request.setHeader("Content-Type", "text/html; charset=utf-8"); 
        request.setURI(new URI(URL)); 

        // Crashes after executing this line
        HttpResponse response = client.execute(request); 

        in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); 

        StringBuffer sb = new StringBuffer(""); 
        String line = ""; 

        String NL = System.getProperty("line.separator"); 
        while ((line = in.readLine()) != null)  
        { 
            sb.append(line + NL); 
        } 
        in.close(); 
        String page = sb.toString();

        //System.out.println(page); 
        return page; 
    }  
    finally  
    { 
        if (in != null)  
        { 
            try  
            { 
                in.close(); 
            }  
            catch (IOException e)     
            { 
                Log.d("BBB", e.toString()); 
            } 
        } 
    } 
}
</code></pre>

<p>This crash happends after this line:</p>

<pre><code>HttpResponse response = client.execute(request);
</code></pre>

<p>It then simply jumps to the <code>finally</code> part and all i can get from the exception message is that something was <code>null</code>. That's all it says.</p>

<p>Anyone any idea what the problem could be?</p>

<hr>

<p>Screenshot of the Exception description:</p>

<p><img src="http://i.stack.imgur.com/QVVue.png" alt="enter image description here"></p>
