Java Utililty Methods Unzip ZipFile

List of utility methods to do Unzip ZipFile

Description

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

Method

byte[]unzip(byte[] zippedBytes)
unzip
int sChunk = 8192;
ByteArrayInputStream in = new ByteArrayInputStream(zippedBytes);
GZIPInputStream zipin = new GZIPInputStream(in);
byte[] buffer = new byte[sChunk];
ByteArrayOutputStream out = new ByteArrayOutputStream();
int length;
while ((length = zipin.read(buffer, 0, sChunk)) != -1)
    out.write(buffer, 0, length);
...
booleanunzip(File srcFile, File toDir)
unzip
return unzip(srcFile.toPath(), toDir.toPath());
voidunzip(final File zip, final File patchDir)
unpack...
try (final ZipFile zipFile = new ZipFile(zip)) {
    unzip(zipFile, patchDir);
    zipFile.close();
Fileunzip(final File zipFile, final String suffix)
unzip
File ret = null;
try (final FileInputStream fis = new FileInputStream(zipFile);
        final ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis))) {
    ZipEntry entry;
    while ((entry = zis.getNextEntry()) != null) {
        if (entry.getName().endsWith(suffix)) {
            ret = Files.createTempFile(entry.getName() + "-", suffix).toFile();
            ret.deleteOnExit();
...
voidunzip(ZipEntry entry, ZipFile zipfile, File explodedDir)
unzip
if (entry.isDirectory()) {
    new File(explodedDir, entry.getName()).mkdirs();
    return;
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();
voidunzip(ZipFile zip, File fileDir)
Unzips a zipfile to a destination directory.
for (Enumeration<? extends ZipEntry> en = zip.entries(); en.hasMoreElements();) {
    ZipEntry ze = en.nextElement();
    long size = ze.getSize();
    String name = ze.getName();
    File zeFile = new File(fileDir, name);
    if (name.charAt(name.length() - 1) == '/') {
        zeFile.mkdirs();
    } else {
...
voidunzip(ZipFile zipFile, File dest)
Unzip a zip file into a directory.
Enumeration<? extends ZipEntry> entries = zipFile.entries();
if (dest.exists() && dest.isDirectory()) {
    while (entries.hasMoreElements()) {
        ZipEntry entry = entries.nextElement();
        if (!entry.isDirectory()) {
            File destFile = new File(dest, entry.getName());
            createFileWithPath(destFile);
            InputStream in = new BufferedInputStream(zipFile.getInputStream(entry));
...
voidunzip(ZipFile zipFile, File destDir)
Unzip.
Enumeration entries;
try {
    entries = zipFile.entries();
    while (entries.hasMoreElements()) {
        ZipEntry entry = (ZipEntry) entries.nextElement();
        if (!entry.isDirectory()) {
            File destFile = new File(destDir, entry.getName());
            File destFileDir = destFile.getParentFile();
...
voidunzip(ZipFile zipFile, File destDirectory)
Unzips a zipFile to the specified directory.
if (!destDirectory.exists()) {
    destDirectory.mkdir();
} else {
    if (!destDirectory.isDirectory()) {
        throw new Exception("The destDirectory file already exists and is not a directory");
Enumeration enumer = zipFile.entries();
...
voidunzip(ZipFile zipFile, File dstDir)
Unzips the given zip file to the given destination directory extracting only those entries the pass through the given filter.
unzip(zipFile, dstDir, dstDir, 0);