public String get(String url) { HttpClient client = new DefaultHttpClient(); StringBuilder builder = new StringBuilder(); HttpGet myget = new HttpGet(url); try { HttpResponse response = client.execute(myget); BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); for (String s = reader.readLine(); s != null; s = reader.readLine()) { builder.append(s); } } catch (Exception e) { System.out.println("调用失败:" + e.getMessage()); } return builder.toString(); } public String post(String url, List <NameValuePair> params) { String retSrc = null; try { HttpPost request = new HttpPost(url); request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); // 发送请求 HttpResponse httpResponse = new DefaultHttpClient().execute(request); retSrc = EntityUtils.toString(httpResponse.getEntity()); } catch (Exception e) { System.out.println("调用失败:" + e.getMessage()); } return retSrc; }