Android 解析 socket 或 http 流中文编码
2010-02-27 01:34:00 来源:WEB开发网核心提示:public String getHttpContent(String htmlurl) throws Exception{HttpClient hc = new DefaultHttpClient();HttpGet get = new HttpGet(htmlUrl);HttpResponse rp = hc.ex
public String getHttpContent(String htmlurl) throws Exception{
HttpClient hc = new DefaultHttpClient();
HttpGet get = new HttpGet(htmlUrl);
HttpResponse rp = hc.execute(get);
if (rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
return EntityUtils.toString(rp.getEntity()).trim();
}else{
return null;
}
}
apache的这些类用起来还真是方便,以后还要多多学习
[]
更多精彩
赞助商链接