Here you can find the source of unzip(byte[] bytes, String encoding)
public static String unzip(byte[] bytes, String encoding)
//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 { public static String unzip(byte[] bytes, String encoding) { if (bytes == null) { return null; } else if (bytes.length == 0) { return ""; }/*from ww w . j ava 2 s .com*/ try (ByteArrayInputStream input = new ByteArrayInputStream(bytes); GZIPInputStream gin = new GZIPInputStream(input); ByteArrayOutputStream out = new ByteArrayOutputStream();) { byte[] buffer = new byte[1024 * 8]; int n; while ((n = gin.read(buffer)) >= 0) { out.write(buffer, 0, n); } out.flush(); return out.toString("UTF-8"); } catch (IOException e) { e.printStackTrace(); } return null; } }