码迷,mamicode.com
首页 > 其他好文 > 详细

img图片

时间:2016-06-02 09:38:26      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

public static String httpclient_get(String url) { String result = ""; HttpGet get = new HttpGet(url); HttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, 10 * 1000); HttpConnectionParams.setSoTimeout(params, 5 * 1000); HttpClient client = new DefaultHttpClient(params); try { HttpResponse httpResponse = client.execute(get); if (httpResponse.getStatusLine().getStatusCode() == 200) { HttpEntity entity = httpResponse.getEntity(); result = EntityUtils.toString(entity, "utf-8"); } } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; }

 

img图片

标签:

原文地址:http://www.cnblogs.com/hnpy/p/5551771.html

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