public static byte[] decompressGZIP(byte[] buffer) throws IOException {
        // Wrap the buffer in a ByteArrayInputStream and extract the decompressed pieces
        // into a ByteArrayOutputStream.
        ByteArrayInputStream bytesIn = new ByteArrayInputStream(buffer);
        GZIPInputStream gzipIn = new GZIPInputStream(bytesIn);
        ByteArrayOutputStream bytesBuffer = new ByteArrayOutputStream();
        byte[] chunkBuffer = new byte[65536];
        for (int bytesRead = gzipIn.read(chunkBuffer);
             bytesRead > 0;
             bytesRead = gzipIn.read(chunkBuffer)) {
            // Push this chunk into the ByteArrayOutputStream
            bytesBuffer.write(chunkBuffer, 0, bytesRead);
        }
        gzipIn.close();
        return bytesBuffer.toByteArray();
    }
public static byte [ ] decompressGZIP ( byte [ ] buffer ) throws IOException { ByteArrayInputStream bytesIn = new ByteArrayInputStream ( buffer ) ; GZIPInputStream gzipIn = new GZIPInputStream ( bytesIn ) ; ByteArrayOutputStream bytesBuffer = new ByteArrayOutputStream ( ) ; byte [ ] chunkBuffer = new byte [ 65536 ] ; for ( int bytesRead = gzipIn . read ( chunkBuffer ) ; bytesRead > 0 ; bytesRead = gzipIn . read ( chunkBuffer ) ) { bytesBuffer . write ( chunkBuffer , 0 , bytesRead ) ; } gzipIn . close ( ) ; return bytesBuffer . toByteArray ( ) ; }
Decompress the given buffer using GZIP, returning the result as a byte[].

@param buffer        Buffer contain data to decompress.
@return              Decompressed data as a byte[].
@throws IOException  If an error occurs reading from the stream, etc.