首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

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

2012-09-27 
Android下载网址链接并获取下载的文本URI utry {u new URI(http://www.weather.com.cn/data/sk/101010

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();
}     

热点排行
Bad Request.