Java Uncompress Byte Array unzip(byte[] data)

Here you can find the source of unzip(byte[] data)

Description

unzip

License

Open Source License

Declaration

public static byte[] unzip(byte[] data) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

import java.io.IOException;
import java.io.InputStream;

import java.util.zip.GZIPInputStream;

public class Main {
    public static byte[] unzip(byte[] data) throws IOException {
        InputStream in = new ByteArrayInputStream(data);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {/*w  w  w  .j a v a2  s . c  om*/
            in = new GZIPInputStream(in);
            byte[] buffer = new byte[65536];
            int noRead;
            while ((noRead = in.read(buffer)) != -1) {
                out.write(buffer, 0, noRead);
            }
        } finally {
            try {
                out.close();
            } catch (Exception e) {
            }
        }
        return out.toByteArray();
    }
}

Related

  1. unzip(byte[] compressedByte)
  2. unzip(byte[] compressedData)
  3. unzip(byte[] content)
  4. unzip(byte[] content)
  5. unZip(byte[] contents)
  6. unZip(byte[] data)
  7. unzip(byte[] data)
  8. unzip(byte[] datas)
  9. unzip(byte[] in)