论坛首页 Java企业应用论坛

HttpClient的使用1

浏览 1403 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2011-11-10  
public static String getUrlResponse(String url) {
        try {
            HttpGet get = new HttpGet(url);
            HttpClient client = new DefaultHttpClient();
            HttpResponse response = client.execute(get);
            HttpEntity entity = response.getEntity();
            return convertStreamToString(entity.getContent());
        } catch (Exception e) {
            return null;        
          }
        return null;
    }

 

论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics