Java Unzip File uncompress(ZipInputStream zipIn)

Here you can find the source of uncompress(ZipInputStream zipIn)

Description

uncompress

License

Apache License

Declaration

public static byte[] uncompress(ZipInputStream zipIn) throws IOException 

Method Source Code

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

import java.io.ByteArrayOutputStream;

import java.io.IOException;

import java.util.zip.ZipInputStream;

public class Main {
    public static byte[] uncompress(ZipInputStream zipIn) throws IOException {
        if (zipIn.getNextEntry() == null) {
            return null;
        }//from w w  w  .j  a  v  a2  s  .c  o m

        final int tmpBufSize = 1024;
        final byte[] tmpBuf = new byte[tmpBufSize];
        byte[] output = null;

        try (final ByteArrayOutputStream st = new ByteArrayOutputStream();) {

            int count = 0;
            while ((count = zipIn.read(tmpBuf, 0, tmpBufSize)) != -1) {
                st.write(tmpBuf, 0, count);
            }
            output = st.toByteArray();
        }

        return output;
    }
}

Related

  1. uncompress(String chemin, String tempPrefix)
  2. uncompress(String compressedValue)
  3. uncompress(String inputCompressedFile, File outputFile)
  4. uncompress(String inputFile, String toDir)
  5. uncompress(String str)
  6. uncompressDirectory(File zipSource, File target)
  7. uncompressEveryFileFromDirectory(File srcPath, File dstPath)
  8. unCompressGzipFile(String path)
  9. uncompressZipEntry(ZipInputStream zis, ZipEntry zipEntry, String dest)