HttpResponse 内容解压

来源:互联网 发布:石家庄网络教育 编辑:程序博客网 时间:2024/06/07 15:01
</pre><pre name="code" class="java">最近做了一个抓取的项目,在HttpClient访问过程中,遇到了压缩的Response解压如下:GZIPInputStream gis =new GZIPInputStream(response.getEntity().getContent());int len = -1;byte [] b1 =new byte[1024];StringBuilder sb = new StringBuilder();ByteArrayOutputStream bos = new ByteArrayOutputStream();while((len = gis.read(b1)) != -1){bos.write(b1, 0, len);}System.out.println(bos.toString("UTF-8"));


0 0