public String download(String urlStr) {
StringBuilder sb = new StringBuilder()
try {// 创建一个URL对象
url = new URL("http://www.baidu.com");
// 创建一个Http连接
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
BufferedReader buffer = new BufferedReader(new InputStreamReader(
urlConn.getInputStream()));
System.out.println("buffer");
// 逐行读数据
String line = null;
while ((line = buffer.readLine()) != null) {
System.out.println("line" + line);
sb.append(line);
}
Log.e("RS", sb.toString());
} catch (Exception e) {
e.printStackTrace();
} finally {
buffer.close();
urlConn.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
return sb.toString();
}