Java Uncompress Byte Array unZip(byte[] data)

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

Description

un Zip

License

Apache License

Declaration

public static byte[] unZip(byte[] data) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

import java.util.zip.ZipInputStream;

public class Main {

    public static byte[] unZip(byte[] data) {
        byte[] b = null;
        try {//from w w w .j av  a 2s . c  om
            ByteArrayInputStream bis = new ByteArrayInputStream(data);
            ZipInputStream zip = new ZipInputStream(bis);
            while (zip.getNextEntry() != null) {
                byte[] buf = new byte[1024];
                int num = -1;
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                while ((num = zip.read(buf, 0, buf.length)) != -1) {
                    baos.write(buf, 0, num);
                }
                b = baos.toByteArray();
                baos.flush();
                baos.close();
            }
            zip.close();
            bis.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return b;
    }
}

Related

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