我正在使用HttpClient最新版本(4.x).而现在我正在尝试做一个GET请求.我刚刚发布了一个Get请求.
这是我的代码;
public class Poster {
static boolean routing1 = true, routing2 = true;
static int counter1 = 0, counter2 = 0;
DefaultHttpClient oHtp = null;
HttpGet oHGet = null;
HttpResponse oHRes = null;
private void test(String fullAddress) throws Exception {
oHtp = new DefaultHttpClient();
oHGet = new HttpGet(fullAddress);
HttpResponse response = oHtp.execute(oHGet);
System.out.print(response.getStatusLine());
HttpEntity entity = response.getEntity();
if (entity != null) {
entity = new BufferedHttpEntity(entity);
// System.out.println(EntityUtils.toString(entity));
System.out.print("\t entity is retrieved... ");
}
oHtp.getConnectionManager().shutdown();
}
}
Run Code Online (Sandbox Code Playgroud)
我只是很好地执行它.首先是
new …Run Code Online (Sandbox Code Playgroud)