Testing Code:
//创建默认的httpClient实例.
HttpClient httpclient = new DefaultHttpClient();
try {
//创建httpget.
HttpGet httpget = new HttpGet("http://www.baidu.com/");
System.out.println("executing request " + httpget.getURI());
//执行get请求.
HttpResponse response = httpclient.execute(httpget);
//获取响应实体
HttpEntity entity = response.getEntity();
System.out.println("--------------------------------------");
//打印响应状态
System.out.println(response.getStatusLine());
if (entity != null) {
//打印响应内容长度
System.out.println("Response content length: " + entity.getContentLength());
//打印响应内容
System.out.println("Response content: " + EntityUtils.toString(entity));
}
System.out.println("------------------------------------");
} finally {
//关闭连接,释放资源
httpclient.getConnectionManager().shutdown();
}
|
相关推荐
struts2 android httpclient 上传文件 客服端 服务器端 亲测通过
NULL 博文链接:https://javasam.iteye.com/blog/2117845
HttpClient 基本用法,HttpClient 基本用法
Http协议使用封装jar包(commons-codec-1.3.jar、commons-httpclient-3.1.jar、commons-logging-1.1.jar) 简单使用方法: public static void main(String[] args) { // String str1 = "...;...
HttpClient 功能jar包 HttpClient 功能jar包 HttpClient 功能jar包 HttpClient 功能jar包
HttpClient是最常用的类库,不可不学。
commons-httpclient,java中使用httpclient中使用的扩展工具
HttpURLConnection与HttpClient的区别: HttpClient是个很不错的...HttpURLConnection是java的标准类,可以实现简单的基于URL请求、响应功能,什么都没封装,用起来太原始,比如重访问的自定义,以及一些高级功能等。
HttpClient 是 Apache Jakarta Common 下的子项目,可以用来提供高效的、最新的、...HttpClient 已经应用在很多的项目中,比如 Apache Jakarta 上很著名的另外两个开源项目 Cactus 和 HTMLUnit 都使用了 HttpClient。
使用HttpClient必须的jar包 使用HttpClient必须的jar包 使用HttpClient必须的jar包
httpClient 教程 使用事例 单向认证
httpclient使用教程
HttpClient汇总工具类 HttpClient汇总工具类HttpClient汇总工具类HttpClient汇总工具类
httpClient组件使用说明,搭建,所需jar包,简单应用,例子。适用于初级学员
HttpClient与Asynctask与服务器的结合使用
一个HttpClient的post提交文件的小demo,之前找了好多CSDN的文档,文件,很多都需要积分下载,只是个小demo,故免费分享供初学者学习。
使用httpClient进行代理