Java Unzip ZipEntry unZipFile(File destFile, ZipFile zipFile, ZipEntry entry)

Here you can find the source of unZipFile(File destFile, ZipFile zipFile, ZipEntry entry)

Description

un Zip File

License

Open Source License

Declaration

private static void unZipFile(File destFile, ZipFile zipFile, ZipEntry entry) throws IOException 

Method Source Code

//package com.java2s;
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Main {
    private static int bufSize = 2048;

    private static void unZipFile(File destFile, ZipFile zipFile, ZipEntry entry) throws IOException {
        InputStream inputStream;/*ww w. j  a  v  a 2s  . co  m*/
        FileOutputStream fileOut;
        if (entry.isDirectory()) {
            destFile.mkdirs();
        } else {
            File parent = destFile.getParentFile();
            if (parent != null && !parent.exists()) {
                parent.mkdirs();
            }

            inputStream = zipFile.getInputStream(entry);

            fileOut = new FileOutputStream(destFile);
            byte[] buf = new byte[bufSize];
            int readedBytes;
            while ((readedBytes = inputStream.read(buf)) > 0) {
                fileOut.write(buf, 0, readedBytes);
            }
            fileOut.close();

            inputStream.close();
        }
    }
}

Related

  1. unzipEntry(ZipInputStream zin, File f)
  2. unzipEntry(ZipInputStream zis, File newFile)
  3. unzipEntry(ZipInputStream zis, File out)
  4. unzipEntry(ZipInputStream zis, File targetFile)
  5. unzipEntryToFolder(ZipEntry entry, InputStream zis, File destFolder)
  6. unzipFile(ZipFile archive, File targetFile, ZipEntry entry)
  7. unzipSingleEntry(ZipInputStream zin, File toFile)