使用httpclient对zip格式的响应数据解压
2015-07-31 10:42
591 查看
HttpResponse response = httpClient.execute(httpPost); //对zip进行解压 response.setEntity(new GzipDecompressingEntity(response.getEntity()));//在这里特殊处理一下就行 HttpEntity entity = response.getEntity(); String responseXml = EntityUtils.toString(entity);//因为上面已经对zip解压。如果上面没有对zip解压,就会出现乱码
更加完善的因为还要做个判断,如果是zip格式,然后就行解压。否则不做解压处理
HttpResponse response = httpClient.execute(httpPost); HttpEntity entity = response.getEntity(); if (entity.getContentEncoding().toString().equalsIgnoreCase("Content-Encoding: gzip")) {//判断是否是zip格式 //对zip进行解压 response.setEntity(new GzipDecompressingEntity(response.getEntity())); entity = response.getEntity(); } String responseXml = EntityUtils.toString(entity);
相关文章推荐
- CentOS下httpd与tomcat整合
- TCP和UDP之间的区别和联系
- 理解TCP为什么需要进行三次握手
- Android安卓获取网络状态
- web网络请求过程_PHP版(待更新...)
- android iptables 屏蔽某个app网络访问
- android 网络访问-图片处理优秀开源项目
- tcp ip协议笔记(2)——链路层
- Android 轮播图,网络图片,缓存
- http://blog.sina.com.cn/s/blog_4a5dbd380101f031.html
- 神经网络简史
- 4G网络技术及应用
- linux初学(十六)之linux网络基础配置(以失败而告终,下次再弄吧)
- Nginx的TCP负载均衡介绍
- 简析HTTPS和HTTP的区别
- 完美网络(优先队列)
- [转载] 读《UNIX网络编程 卷1:套接字联网API》
- Demo XML 、 JSON 解析 AND 网络HTTP请求
- HttpClient结合Struts2开发移动应用后台
- Https要点