Here you can find the source of decompress(byte[] str)
public static byte[] decompress(byte[] str) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.zip.GZIPInputStream; public class Main { public static byte[] decompress(byte[] str) throws Exception { int BUFFER = 8192; byte data[] = new byte[BUFFER]; int count; byte out[]; if (str == null || str.length == 0) { return null; }/* w w w . j av a 2 s. co m*/ System.out.println("Input byte[] length : " + str.length); GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(str)); // write the files to the disk ByteArrayOutputStream fos = new ByteArrayOutputStream(); while ((count = gis.read(data, 0, BUFFER)) != -1) { fos.write(data, 0, count); } fos.flush(); fos.close(); out = fos.toByteArray(); System.out.println("Output String lenght : " + out.length); return out; } }