标签:
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);
标签:
原文地址:http://www.cnblogs.com/aisam/p/4691518.html