首页 > Web开发 > 详细

httpClient(Get)进行网络请求

时间:2016-03-23 13:04:29      阅读:184      评论:0      收藏:0      [点我收藏+]

//请求网络数据

String result = "";
    StringBuffer str = new StringBuffer(ur);

    HttpGet get = new HttpGet(str.toString());
    HttpParams parms = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(parms, 5000);
    HttpConnectionParams.setSoTimeout(parms, 5000);
    HttpClient client = new DefaultHttpClient(parms);
    try {
        HttpResponse execute = client.execute(get);
        if (execute.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = execute.getEntity();
            result = EntityUtils.toString(entity, "utf-8");

        }

httpClient(Get)进行网络请求

原文:http://www.cnblogs.com/weiyangge/p/5310569.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!