Java Utililty Methods Unzip to Folder

List of utility methods to do Unzip to Folder

Description

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

Method

voidunzip(String zip, String path)
unzip
final int BUF_SIZE = 2048;
FileInputStream fis = new FileInputStream(zip);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
    int count;
    byte data[] = new byte[BUF_SIZE];
    FileOutputStream fos = new FileOutputStream(new File(path, entry.getName()));
...
voidunzip(String zip, String unzipDir, int bufferSize)
Unzips a zipFile in unzip directory.
createDirs(unzipDir);
ZipFile zipFile = new ZipFile(zip);
try {
    Enumeration entries = zipFile.entries();
    while (entries.hasMoreElements()) {
        ZipEntry entry = (ZipEntry) entries.nextElement();
        File file = new File(unzipDir, entry.getName());
        if (entry.isDirectory()) {
...
booleanUnzip(String zipFile, String outputDirectory)
Unzip a zipped file (eg.
String outDir = outputDirectory;
if (!outDir.endsWith("/") && !outDir.endsWith("\\"))
    outDir += File.separator;
BufferedOutputStream dest = null;
BufferedInputStream is = null;
int BUFFER = 2048;
ZipEntry entry;
ZipFile zipfile;
...
voidunzip(String zipFile, String targetFolder)
Unzip the component file to the user folder.
Exception exception = null;
ZipFile zip = new ZipFile(zipFile);
byte[] buf = new byte[8192];
try {
    Enumeration<ZipEntry> enumeration = (Enumeration<ZipEntry>) zip.entries();
    while (enumeration.hasMoreElements()) {
        ZipEntry entry = enumeration.nextElement();
        File file = new File(targetFolder, entry.getName());
...
voidunzip(String zipFile, String targetFolder, String... fileSuffixes)
unzip
unzip(zipFile, targetFolder, true, fileSuffixes);
voidunzip(String zipFile, String targetPath)
unzip
log.log(Level.INFO, "Extracting {0} ...", zipFile);
log.log(Level.INFO, "...target directory: {0}", targetPath);
File path = new File(targetPath);
path.delete();
path.mkdirs();
BufferedOutputStream dest = null;
FileInputStream fis = new FileInputStream(zipFile);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
...
voidunzip(String zipFileName, String outputDirectory)
unzip
ZipInputStream in = new ZipInputStream(new FileInputStream(zipFileName));
ZipEntry z;
while ((z = in.getNextEntry()) != null) {
    System.out.println("unziping " + z.getName());
    if (z.isDirectory()) {
        String name = z.getName();
        name = name.substring(0, name.length() - 1);
        File f = new File(outputDirectory + File.separator + name);
...
voidunzip(String zipFileName, String targetFolderPath)
unzip
Enumeration entries;
ZipFile zipFile;
try {
    File targetFolder = new File(targetFolderPath);
    if (!targetFolder.exists()) {
        targetFolder.mkdirs();
    String canonicalTargetPath = targetFolder.getCanonicalPath();
...
voidunzip(String zipFileName, String targetPath)
unzip
ZipFile zipFile = new ZipFile(zipFileName);
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
    ZipEntry entry = entries.nextElement();
    if (entry.isDirectory()) {
        (new File(targetPath, entry.getName())).mkdir();
    File outputFile = new File(targetPath, entry.getName());
...
voidunzip(String zipFileName, String unzipdir)
unzip
try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(zipFileName)))) {
    ZipEntry entry = null;
    while ((entry = zis.getNextEntry()) != null) {
        extractEntryContent(zis, entry, unzipdir);
    System.out.println(
            "ZIP file's contents have been extracted to " + (new File(unzipdir)).getAbsolutePath());
} catch (IOException e) {
...