public static String httpGet(String url) { // get请求返回结果 String strResult = ""; try { DefaultHttpClient client = new DefaultHttpClient(); // 发送get请求 HttpGet request = new HttpGet(url); HttpResponse response = client.execute(request); /** 请求发送成功,并得到响应 **/ if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { /** 读取服务器返回过来的json字符串数据 **/ strResult = EntityUtils.toString(response.getEntity()); } } catch (IOException e) { System.out.println("get请求提交失败:" + url); } return strResult; }
Thanks,
Ivan