码迷,mamicode.com
首页 > Web开发 > 详细

HttpClient的用法

时间:2015-03-01 10:24:19      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

1 HttpClient httpClient = new DefaultHttpClient();
2 HttpGet httpGet = new HttpGet(url);
3 httpGet.addHeader("Accept-Language","zh-CN");//指定返回中文
4 HttpResponse httpResponse = httpClient.execute(httpGet);
5 if(httpResponse.getStatusLine().getStatusCode() == 200){
6     HttpEntity entity = httpResponse.getEntity();
7     String response = EntityUtils.toString(entity,"utf-8");
8 }

 

HttpClient的用法

标签:

原文地址:http://www.cnblogs.com/plmmlp09/p/4306634.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!