韩立66

导航

 
public static String get(String url) {
    CloseableHttpResponse response null;
    BufferedReaderin = null;
    String result = "";
    try {
  
      HttpGethttpGet = new HttpGet(url);
      response = httpClient.execute(httpGet);
  
      in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
      StringBuffersb = new StringBuffer("");
      String line = "";
      String NL = System.getProperty("line.separator");
      while ((line = in.readLine()) != null) {
        sb.append(line + NL);
      }
      in.close();
      result = sb.toString();
    catch (IOException e) {
      e.printStackTrace();
    
    finally {
      try {
        if (null != response) response.close();
      catch (IOException e) {
        e.printStackTrace();
      }
    }
    return result;
  }
    return result;
  }
posted on 2017-12-27 10:59  韩立66  阅读(700)  评论(0)    收藏  举报