Here you can find the source of unGzip(byte[] str, String charset)
public static String unGzip(byte[] str, String charset) throws IOException
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPInputStream; public class Main { public static String unGzip(byte[] str, String charset) throws IOException { if (str == null || str.length == 0) { return null; }/* w w w . j ava 2 s . c o m*/ ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = new ByteArrayInputStream(str); GZIPInputStream gunzip = new GZIPInputStream(in); byte[] buffer = new byte[256]; int n; while ((n = gunzip.read(buffer)) >= 0) { out.write(buffer, 0, n); } out.flush(); String body = out.toString(charset); gunzip.close(); out.close(); in.close(); return body; } }