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

voidunzip(File jarFile, File destDir)
unzip
JarFile jar = null;
try {
    if (!destDir.exists()) {
        destDir.mkdir();
    jar = new JarFile(jarFile);
    Enumeration<JarEntry> enumEntries = jar.entries();
    InputStream input = null;
...
voidunzip(File sourceFile, File rootDir)
unzip
final ZipFile zipFile = new ZipFile(sourceFile);
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
    final ZipEntry zipEntry = entries.nextElement();
    String name = zipEntry.getName();
    final File file = new File(rootDir, name);
    if (name.endsWith("/")) { 
        if (!file.exists() && !file.mkdirs()) {
...
voidunzip(File sourceZipfile, File directory)
unzip
try (ZipFile zfile = new ZipFile(sourceZipfile);) {
    Enumeration<? extends ZipEntry> entries = zfile.entries();
    while (entries.hasMoreElements()) {
        ZipEntry entry = entries.nextElement();
        File file = new File(directory, entry.getName());
        if (entry.isDirectory()) {
            file.mkdirs();
        } else {
...
voidunzip(File src, File dest)
Unzip the the file at the specified location.
dest.mkdirs();
BufferedOutputStream out = null;
BufferedInputStream is = null;
try {
    ZipEntry entry;
    ZipFile zip = new ZipFile(src);
    for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements();) {
        entry = e.nextElement();
...
voidunzip(File src, File target)
unzip a file to a folder
InputStream in = new FileInputStream(src);
ZipInputStream zi = new ZipInputStream(in);
try {
    String fn;
    ZipEntry ze;
    File f;
    OutputStream out;
    int l;
...
booleanunzip(File srcZipFile, File tgtDir)
Unzips the contents of a zip file to a directory
if (!srcZipFile.exists() || !tgtDir.exists()) {
    return false;
if (!tgtDir.isDirectory()) {
    return false;
try {
    ZipFile zipFile = new ZipFile(srcZipFile);
...
voidunzip(File tarFile, File destinationDir)
unzip
ZipInputStream zis = null;
final int BUFFER = 2048;
try {
    zis = new ZipInputStream(new FileInputStream(tarFile));
    ZipEntry zipEntry = zis.getNextEntry();
    while (zipEntry != null) {
        File destPath = new File(destinationDir, zipEntry.getName());
        File parent = destPath.getParentFile();
...
Listunzip(File target)
Unzips a file and return a list of the unziped files.
List<File> unzippedFiles = new ArrayList<>();
BufferedOutputStream dest = null;
FileInputStream fis = new FileInputStream(target);
ZipEntry entry = null;
try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis))) {
    while ((entry = zis.getNextEntry()) != null) {
        int count;
        byte data[] = new byte[BUFFER];
...
longunzip(File targetZip, File dirToExtract)
unzip
if (logger.isLoggable(Level.FINE)) {
    logger.fine("Unzipping file [" + targetZip.getAbsolutePath() + "] with size [" + targetZip.length()
            + "] to [" + dirToExtract.getAbsolutePath() + "]");
long totalSize = 0;
final int bufferSize = 4098;
byte data[] = new byte[bufferSize];
ZipFile zipFile = new ZipFile(targetZip);
...
voidunzip(File zip)
unzip a file
try {
    String destinationDirName = zip.getName().substring(0, zip.getName().length() - ".zip".length());
    File destinationDir = new File(zip.getParentFile(), destinationDirName);
    unzipHelper(zip, destinationDir);
} catch (IOException e) {
    e.printStackTrace();