Here you can find the source of unzip(byte[] compressedByte)
public static final String unzip(byte[] compressedByte) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { public static final String unzip(byte[] compressedByte) throws Exception { ByteArrayOutputStream out = null; ByteArrayInputStream in = null; ZipInputStream zin = null; String decompressed = null; try {/*from w w w . jav a 2s. c o m*/ out = new ByteArrayOutputStream(); in = new ByteArrayInputStream(compressedByte); zin = new ZipInputStream(in); ZipEntry entry = zin.getNextEntry(); byte[] buffer = new byte[1024]; int offset = -1; while ((offset = zin.read(buffer)) != -1) { out.write(buffer, 0, offset); } decompressed = new String(out.toByteArray(), "utf-8"); } catch (Exception e) { decompressed = null; } finally { if (zin != null) { try { zin.close(); } catch (Exception e) { } } if (in != null) { try { in.close(); } catch (Exception e) { } } if (out != null) { try { out.close(); } catch (Exception e) { } } } return decompressed; } public static final String unzip(byte[] compressedByte, String name) throws Exception { ByteArrayOutputStream out = null; ByteArrayInputStream in = null; ZipInputStream zin = null; String decompressed = null; try { out = new ByteArrayOutputStream(); in = new ByteArrayInputStream(compressedByte); zin = new ZipInputStream(in); ZipEntry entry = zin.getNextEntry(); while (!name.equalsIgnoreCase(entry.getName())) { entry = zin.getNextEntry(); } byte[] buffer = new byte[1024]; int offset = -1; while ((offset = zin.read(buffer)) != -1) { out.write(buffer, 0, offset); } decompressed = new String(out.toByteArray(), "utf-8"); } catch (Exception e) { e.printStackTrace(); decompressed = null; } finally { if (zin != null) { try { zin.close(); } catch (Exception e) { } } if (in != null) { try { in.close(); } catch (Exception e) { } } if (out != null) { try { out.close(); } catch (Exception e) { } } } return decompressed; } }