当前位置: 代码迷 >> Android >> Android上载网址链接并获取上载的文本
  详细解决方案

Android上载网址链接并获取上载的文本

热度:67   发布时间:2016-05-01 13:50:47.0
Android下载网址链接并获取下载的文本

URI u;
try {
u = new URI("http://www.weather.com.cn/data/sk/101010100.html");
DefaultHttpClient httpclient = new DefaultHttpClient();  
HttpGet httpget = new HttpGet(u);    
ResponseHandler<String> responseHandler = new BasicResponseHandler();    
String content = "";
content = httpclient.execute(httpget, responseHandler);
//content = new String(content.getBytes("ISO-8859-1"),"UTF-8");
com.Log(content);
}catch (URISyntaxException e) {
e.printStackTrace();
}catch (ClientProtocolException e) {
e.printStackTrace();
}catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}     
  相关解决方案