Java Unzip InputStream decompress(InputStream is, OutputStream os)

Here you can find the source of decompress(InputStream is, OutputStream os)

Description

decompress

License

Open Source License

Declaration

public static void decompress(InputStream is, OutputStream os)
        throws Exception 

Method Source Code

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

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

import java.util.zip.InflaterInputStream;

public class Main {
    private static final int BUFFER = 1024;

    public static void decompress(InputStream is, OutputStream os)
            throws Exception {
        InflaterInputStream gis = new InflaterInputStream(is);
        int count;
        byte data[] = new byte[BUFFER];
        while ((count = gis.read(data, 0, BUFFER)) != -1) {
            os.write(data, 0, count);/*from  w  w  w  .  j  av  a2  s  . c o m*/
        }
        gis.close();
    }

    public static byte[] decompress(byte[] bt) throws Exception {
        ByteArrayInputStream is = new ByteArrayInputStream(bt);
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        decompress(is, os);
        return os.toByteArray();
    }
}

Related

  1. decompress(ByteArrayInputStream xzStream)
  2. decompress(final int type, final InputStream is, final OutputStream os)
  3. decompress(InputStream input, File destDir)
  4. decompress(InputStream inputStream)
  5. decompressFile(InputStream is, OutputStream os)
  6. decompressStream(InputStream input)
  7. decompressZipArchive(final File zipFile, final File rootDirectoryToUnZip)
  8. unzip(InputStream from, String to, String pattern)