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);

 

相关文章:

  • 2022-12-23
  • 2022-02-23
  • 2022-02-07
  • 2021-11-23
  • 2021-08-08
  • 2022-02-07
猜你喜欢
  • 2021-11-30
  • 2022-12-23
  • 2021-10-27
  • 2022-02-17
  • 2022-01-14
  • 2021-12-20
  • 2021-05-31
相关资源
相似解决方案