运行jar包

jar包下载地址:http://pan.baidu.com/s/1i38b6Ot


实例:

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;

HttpClient client = new HttpClient();
client.getHttpConnectionManager().getParams().setConnectionTimeout(3000);
GetMethod httpGet = new GetMethod("http://www.baidu.com");
try {
	int statusCode = client.executeMethod(httpGet);
	if (statusCode != HttpStatus.SC_OK) { // 打印服务器返回的状态
		System.out.println("Method failed: " + httpGet.getStatusLine());
		httpGet.abort();
	} else {
		resp = httpGet.getResponseBodyAsString();
		if (resp != null) {
			resp = new String(resp.getBytes(), "utf-8");
		}
	}
} catch (HttpException e) {
	e.printStackTrace();
} catch (IOException e) {
	e.printStackTrace();
}