img图片

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

 

posted @ 2016-06-02 08:36  夏夜微凉  阅读(337)  评论(0编辑  收藏  举报