Here you can find the source of decompress(byte[] compressedData)
public static byte[] decompress(byte[] compressedData)
//package com.java2s; /******************************************************************************** * Copyright (c) 2009 Regents of the University of Minnesota * * This Software was written at the Minnesota Supercomputing Institute * http://msi.umn.edu//from w w w . j a v a 2 s . c o m * * All rights reserved. The following statement of license applies * only to this file, and and not to the other files distributed with it * or derived therefrom. This file is made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Minnesota Supercomputing Institute - initial API and implementation *******************************************************************************/ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.DataFormatException; import java.util.zip.Inflater; public class Main { public static byte[] decompress(byte[] compressedData) { byte[] decompressedData; // using a ByteArrayOutputStream to not having to define the result array size beforehand Inflater decompressor = new Inflater(); decompressor.setInput(compressedData); // Create an expandable byte array to hold the decompressed data ByteArrayOutputStream bos = new ByteArrayOutputStream(compressedData.length); byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); if (count == 0 && decompressor.needsInput()) { break; } bos.write(buf, 0, count); } catch (DataFormatException e) { throw new IllegalStateException( "Encountered wrong data format " + "while trying to decompress binary data!", e); } } try { bos.close(); } catch (IOException e) { // ToDo: add logging e.printStackTrace(); } // Get the decompressed data decompressedData = bos.toByteArray(); if (decompressedData == null) { throw new IllegalStateException("Decompression of binary data produced no result (null)!"); } return decompressedData; } }