Java Utililty Methods Unzip File

List of utility methods to do Unzip File

Description

The list of methods to do Unzip File are organized into topic(s).

Method

InputStreamuncompress(final InputStream inputStream)
Uncompress a given byte array input.
return new InflaterInputStream(inputStream);
voiduncompress(final String zipFileName, final String directory)
Uncompress a given zip file named zipFileName over directory named directory.
final ZipInputStream zipIs = new ZipInputStream(new BufferedInputStream(new FileInputStream(zipFileName)));
ZipEntry entry;
int count;
final byte data[] = new byte[BUFFER_SIZE];
while ((entry = zipIs.getNextEntry()) != null) {
    final File file = new File(directory, entry.getName());
    if (meetRequirements(file)) {
        final BufferedOutputStream dest = new BufferedOutputStream(new FileOutputStream(file), BUFFER_SIZE);
...
ArrayListuncompress(String chemin, String tempPrefix)
uncompress
ArrayList<File> result = new ArrayList<File>();
BufferedOutputStream dest = null;
FileInputStream fis = new FileInputStream(chemin);
BufferedInputStream buffi = new BufferedInputStream(fis);
ZipInputStream zis = new ZipInputStream(buffi);
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
    File temp = File.createTempFile(tempPrefix, entry.getName());
...
Stringuncompress(String compressedValue)
Uncompress a string value that was compressed using GZIP.
if (compressedValue == null)
    return null;
ByteArrayInputStream in = new ByteArrayInputStream(compressedValue.getBytes("ISO-8859-1"));
GZIPInputStream gzip = null;
Reader reader = null;
try {
    String value = "";
    gzip = new GZIPInputStream(in);
...
voiduncompress(String inputCompressedFile, File outputFile)
uncompress
GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(inputCompressedFile));
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
byte[] buffer = new byte[1024];
final int offset = 0;
int length;
while ((length = gzipInputStream.read(buffer)) > 0) {
    fileOutputStream.write(buffer, offset, length);
gzipInputStream.close();
fileOutputStream.close();
voiduncompress(String inputFile, String toDir)
uncompress
try {
    FileInputStream tin = new FileInputStream(inputFile);
    CheckedInputStream cin = new CheckedInputStream(tin, new CRC32());
    BufferedInputStream bufferIn = new BufferedInputStream(cin, BUFFER);
    ZipInputStream in = new ZipInputStream(bufferIn);
    ZipEntry z = in.getNextEntry();
    while (z != null) {
        String name = z.getName();
...
Stringuncompress(String str)
uncompress
try {
    if (str == null || str.length() == 0) {
        return str;
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ByteArrayInputStream in = new ByteArrayInputStream(str.getBytes("ISO-8859-1"));
    GZIPInputStream gunzip = new GZIPInputStream(in);
    byte[] buffer = new byte[256];
...
byte[]uncompress(ZipInputStream zipIn)
uncompress
if (zipIn.getNextEntry() == null) {
    return null;
final int tmpBufSize = 1024;
final byte[] tmpBuf = new byte[tmpBufSize];
byte[] output = null;
try (final ByteArrayOutputStream st = new ByteArrayOutputStream();) {
    int count = 0;
...
voiduncompressDirectory(File zipSource, File target)
uncompress Directory
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipSource));
try {
    byte[] readBuffer = new byte[BUFFER_SIZE];
    for (ZipEntry entry = zis.getNextEntry(); entry != null; entry = zis.getNextEntry()) {
        String relativeName = entry.getName();
        if (DEBUG)
            System.out.println("- entry : " + relativeName);
        int start = 0;
...
voiduncompressEveryFileFromDirectory(File srcPath, File dstPath)
Uncompress data to the destination directory.
if (srcPath.isDirectory()) {
    if (!dstPath.exists()) {
        dstPath.mkdirs();
    String files[] = srcPath.list();
    for (int i = 0; i < files.length; i++) {
        uncompressEveryFileFromDirectory(new File(srcPath, files[i]), new File(dstPath, files[i]));
} else {
    ZipInputStream in = null;
    OutputStream out = null;
    try {
        in = new ZipInputStream(new FileInputStream(srcPath));
        in.getNextEntry();
        out = new FileOutputStream(dstPath);
        transfer(in, out);
    } finally {
        if (in != null) {
            in.close();
        if (out != null) {
            out.close();