Here you can find the source of gunzip(byte[] bytes)
public static byte[] gunzip(byte[] bytes) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPInputStream; public class Main { /**/* w w w. j a v a2s . co m*/ * Decompresses the given byte array in the GZIP file format. */ public static byte[] gunzip(byte[] bytes) throws IOException { if (bytes == null) return null; if (bytes.length == 0) return new byte[0]; ByteArrayInputStream bin = new ByteArrayInputStream(bytes); byte[] result = null; try (GZIPInputStream gzip = new GZIPInputStream(bin); ByteArrayOutputStream bout = new ByteArrayOutputStream()) { byte[] buffer = new byte[1024]; int count = -1; while ((count = gzip.read(buffer)) >= 0) bout.write(buffer, 0, count); result = bout.toByteArray(); } return result; } }