Here you can find the source of uncompressGZip(ByteBuffer bytes)
public static String uncompressGZip(ByteBuffer bytes) throws Exception
//package com.java2s; import android.util.Log; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.math.BigDecimal; import java.nio.ByteBuffer; import java.text.DecimalFormat; import java.util.zip.GZIPInputStream; public class Main { static final DecimalFormat df = new DecimalFormat( "###,###,###,###,###,###,###,##0.00"); public static String uncompressGZip(ByteBuffer bytes) throws Exception { Log.w("ZipUtil", "## packed length: " + getKilobytes(bytes.capacity())); GZIPInputStream gzipInputStream = new GZIPInputStream( new ByteArrayInputStream(bytes.array())); OutputStream out = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; int len;/* ww w. j a v a2s .c o m*/ while ((len = gzipInputStream.read(buf)) > 0) { out.write(buf, 0, len); } gzipInputStream.close(); out.close(); String res = out.toString(); Log.i("ZipUtil", "## unpacked length, in KB: " + getKilobytes(res.length())); return res; } public static String getKilobytes(int bytes) { BigDecimal m = new BigDecimal(bytes).divide(new BigDecimal(1024)); return df.format(m.doubleValue()) + " KB"; } }