Java Decompress Byte Array decompress(byte[] data)

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

Description

decompress

License

Apache License

Declaration

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

Method Source Code


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

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[] decompress(byte[] data) {
        ByteArrayOutputStream bout = new ByteArrayOutputStream(1024);

        ZipInputStream zip = new ZipInputStream(new ByteArrayInputStream(data));

        try {//from   w w  w .ja  v  a  2  s  . c  om
            while (true) {

                ZipEntry zipEntry = zip.getNextEntry();

                if (zipEntry == null)
                    break;

                while (true) {
                    int i = zip.read();
                    if (i < 0)
                        break;
                    bout.write(i);
                }
                break;

            }
            zip.close();
        } catch (IOException e) {
        }

        return bout.toByteArray();
    }
}

Related

  1. decompress(byte[] data)
  2. decompress(byte[] data)
  3. decompress(byte[] data)
  4. decompress(byte[] data)
  5. decompress(byte[] data)
  6. decompress(byte[] data, int off, int len)
  7. decompress(byte[] data, int offset, int length)
  8. decompress(byte[] gzipped)
  9. decompress(byte[] in)