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

阅读更多
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();
	}

 走到

bReader = new BufferedReader(new InputStreamReader(
					conn.getInputStream())); 

 就会报空指针错误。为什么呢 ?

 ----------------

  改为 14以下版本。。。就OK。。。

你可能感兴趣的:(android,空指针,bufferedreader)