62,614
社区成员
发帖
与我相关
我的任务
分享
package com.fuou;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
/**
* This example demonstrates the use of the {@link ResponseHandler} to simplify
* the process of processing the HTTP response and releasing associated resources.
*/
public class ClientWithResponseHandler {
public final static void main(String[] args) throws Exception {
HttpClient httpclient = new DefaultHttpClient();
//HttpResponse response = httpclient.execute(httpget);
// HttpGet httpget = new HttpGet("http://www.google.com/");
// System.out.println("executing request " + httpget.getURI());
// Create a response handler
ResponseHandler<String> responseHandler = new BasicResponseHandler();
// String responseBody = httpclient.execute(httpget, responseHandler);
// System.out.println(responseBody);
System.out.println("----------------------------------------");
}
}