org.apache.http.client.HttpClient

 

 

 

org.apache.http.client.HttpClient 用来联网简单,还可以省去编码转换的麻烦。

 

 

public String getHttpContent(String htmlurl) throws Exception{      HttpClient hc = new DefaultHttpClient();         HttpGet get = new HttpGet(htmlUrl);      HttpResponse rp = hc.execute(get);         if (rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {         return EntityUtils.toString(rp.getEntity()).trim();         }else{         return null;         }       }  


 

 

 

你可能感兴趣的:(org.apache.http.client.HttpClient)