1:核心代码
 JSONObject json=(JSONObject) JSON.parse(responseContent); 
	        		byte [] compress=Base64.decodeBase64((json.getString("result").getBytes("UTF-8")));    (org.apache.commons.net.util.Base64)
	        		byte [] umcompress=GZipUtil.uncompress(compress);
	        		String jsons=new String(umcompress,"UTF-8");
2:解压工具类代码如下:
package com.trafree.banking.server.hardcore.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;
public class GZipUtil {
	/**
	 * 解压
	 * 使用gzip进行解压缩
	 * @param compressedStr
	 * @return
	 */
    public static byte[] uncompress(byte[] compressedStr) {
        if (compressedStr == null) {
            return null;
        }
        byte[] decompressed = null;
        try {
        	
            ByteArrayInputStream in = new ByteArrayInputStream(compressedStr);
            GZIPInputStream ginzip = new GZIPInputStream(in);
           
            
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            byte[] buffer = new byte[1024];
            int offset = -1;
            while ((offset = ginzip.read(buffer, 0, buffer.length)) != -1) {
                out.write(buffer, 0, offset);
            }
            decompressed = out.toByteArray();
            in.close();
            ginzip.close();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return decompressed;
    }
}
这样就可以获取到BASE64解码并解压后的报文了,一般在用 JSON 报文格式请求接口时,有可能会出现这样的情况.
原文:https://www.cnblogs.com/kokimiki/p/13362620.html