大家好:
这个包中有几种方法,如HttpGetHttpPost。但是连接方法丢失了。你知道为什么吗?我尝试在HttpGet方法实现之后添加自己的http connect方法。也就是说,新的类httpconnect扩展了httpentityenclosingrequestbase基类。但这不管用。:。-(
你能帮忙吗?谢谢您!

最佳答案

您不必实现任何连接方法。查看官方文档中提供的示例:

HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://localhost/");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
    InputStream instream = entity.getContent();
    int l;
    byte[] tmp = new byte[2048];
    while ((l = instream.read(tmp)) != -1) {
    }
}

参见sources and documentation

关于android - org.apache.http.client.methods,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4468905/

10-10 18:30