public String download (String urlStr){
StringBuffer sb = new StringBuffer();
String line = null;
BufferedReader buffer = null;
try{//创建一个URL对象
url = new URL(urlStr);
//创建一个Http链接
HttpURLConnection urlConn = (HttpURLConnection)url.openConnection();
//使用IO流读取数据
buffer = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
while ((line = buffer.readLine())!= null){
sb.append(line);
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
buffer.close();
}catch(Exception e){
e.printStackTrace();
}
}
return sb.toString();
}