Java Unzip ZipFile unzip(ZipEntry entry, ZipFile zipfile, File explodedDir)

Here you can find the source of unzip(ZipEntry entry, ZipFile zipfile, File explodedDir)

Description

unzip

License

Apache License

Declaration

public static void unzip(ZipEntry entry, ZipFile zipfile, File explodedDir) throws IOException 

Method Source Code


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

import com.google.common.io.ByteStreams;
import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Main {
    public static void unzip(ZipEntry entry, ZipFile zipfile, File explodedDir) throws IOException {

        if (entry.isDirectory()) {
            new File(explodedDir, entry.getName()).mkdirs();
            return;
        }//from ww  w. ja  v  a  2 s .  c om

        File outputFile = new File(explodedDir, entry.getName());
        if (!outputFile.getParentFile().exists()) {
            outputFile.getParentFile().mkdirs();
        }

        BufferedInputStream inputStream = new BufferedInputStream(zipfile.getInputStream(entry));
        BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));

        try {
            ByteStreams.copy(inputStream, outputStream);
        } finally {
            outputStream.close();
            inputStream.close();
        }
    }
}

Related

  1. unzip(byte[] zippedBytes)
  2. unzip(File srcFile, File toDir)
  3. unzip(final File zip, final File patchDir)
  4. unzip(final File zipFile, final String suffix)
  5. unzip(ZipFile zip, File fileDir)
  6. unzip(ZipFile zipFile, File dest)
  7. unzip(ZipFile zipFile, File destDir)
  8. unzip(ZipFile zipFile, File destDirectory)