android 4.0 HttpURLConnection. getInputStream() 为空的问题

Java代码 
public String downTxt(String urlStr) {  
        StringBuffer sBuffer = new StringBuffer();  
        String line = null;  
        BufferedReader bReader = null;  
        try {  
            URL url = new URL(urlStr);  
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();  
            bReader = new BufferedReader(new InputStreamReader(  
                    conn.getInputStream()));  
            while ((line = bReader.readLine()) != null) {  
                sBuffer.append(line);  
            }  
  
        } catch (MalformedURLException e) {  
            e.printStackTrace();  
        } catch (IOException e) {  
            e.printStackTrace();  
        } finally {  
            try {  
                bReader.close();  
            } catch (IOException e) {  
                e.printStackTrace();  
            }  
        }  
  
        return sBuffer.toString();  
    }  

走到
Java代码 
bReader = new BufferedReader(new InputStreamReader(  
                    conn.getInputStream())); 
 
就会报空指针错误。为什么呢 ?
----------------
<uses-sdk android:minSdkVersion="14"/> 改为 7 就能正常运行了。。。

你可能感兴趣的:(android,String)