Here you can find the source of unzip(byte[] content)
public static byte[] unzip(byte[] content) throws IOException
//package com.java2s; /******************************************************************************* * Copyright 2011 Clockwork/*from w ww. j a v a 2 s .c om*/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { public static byte[] unzip(byte[] content) throws IOException { int BUFFER_SIZE = 2048; ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(content)); ZipEntry entry = zin.getNextEntry(); if (entry != null) { int count; byte buffer[] = new byte[BUFFER_SIZE]; BufferedOutputStream bout = new BufferedOutputStream(out, BUFFER_SIZE); while ((count = zin.read(buffer, 0, BUFFER_SIZE)) != -1) bout.write(buffer, 0, count); bout.flush(); bout.close(); zin.close(); } return out.toByteArray(); } }