您的位置:首页 > 理论基础 > 计算机网络

httpClient(Get)解析JSON

2016-07-27 10:15 239 查看
publicstatic String getJson(String str) throws Exception{

                   HttpGet get=new HttpGet(str);

                   HttpClient client=newDefaultHttpClient();

                   HttpResponseresponse=client.execute(get);

                   intcode=response.getStatusLine().getStatusCode();

                   if(HttpStatus.SC_OK==code){

                            String s=EntityUtils.toString(response.getEntity(),"utf-8");

                            return s;

                   }

                   return "";

         }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: