package crawler;
import org.apache.http.client.*;
import org.apache.http.client.methods.*;
class Crawler{
public static void main(String args[]){
HttpClient httpclient = new HttpClient(); // **HERE!!!!!!!!!**
GetMethod getMethod = new GetMethod("http://www.google.com");
int statusCode = httpclient.executeMethod(getMethod);
System.out.println("response=" + getMethod.getResponseBodyAsString());;
getMethod.releaseConnection();
}
}
来自Apache Httpclient的HttpClient。
代码:
@SuppressWarnings("deprecation")
public interface HttpClient
如何解决问题“HttpClient httpclient = new HttpClient();
”?
谢谢!
答案 0 :(得分:0)
HttpClient
是一个界面。你不能这样做。
正确的方法是
HttpClient client = HttpClientBuilder.create().build();
答案 1 :(得分:0)
您无法实例化界面。您必须实现它或创建一个匿名类(仍然是实现)