Java Decompress Byte Array decompress(byte[] compressed)

Here you can find the source of decompress(byte[] compressed)

Description

decompress

License

Creative Commons License

Declaration

public static byte[] decompress(byte[] compressed) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Creative Commons License 

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

import java.util.zip.GZIPInputStream;

public class Main {
    public static byte[] decompress(byte[] compressed) throws IOException {

        GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(compressed));

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int n;//from   ww  w  .  ja v  a 2 s . c  om

        while ((n = gis.read(buffer)) != -1)
            baos.write(buffer, 0, n);

        return baos.toByteArray();

    }
}

Related

  1. decompress(byte[] bytes)
  2. decompress(byte[] bytes)
  3. decompress(byte[] bytes, int bufferSize)
  4. decompress(byte[] compressed)
  5. decompress(byte[] compressed)
  6. decompress(byte[] compressed)
  7. decompress(byte[] compressed)
  8. decompress(byte[] compressed)
  9. decompress(byte[] compressedData)