Java Utililty Methods Zip Directory

List of utility methods to do Zip Directory

Description

The list of methods to do Zip Directory are organized into topic(s).

Method

voidzip(File directory, File base, ZipOutputStream zos)
zip
File[] files = directory.listFiles();
byte[] buffer = new byte[8192];
int read = 0;
for (int i = 0, n = files.length; i < n; i++) {
    if (files[i].isDirectory()) {
        zip(files[i], base, zos);
    } else {
        FileInputStream in = new FileInputStream(files[i]);
...
voidzip(File directory, File base, ZipOutputStream zos, byte[] buffer)
zip
int read = 0;
for (File file : directory.listFiles()) {
    if (file.isDirectory()) {
        zip(file, base, zos, buffer);
    } else {
        FileInputStream in = new FileInputStream(file);
        try {
            ZipEntry entry = new ZipEntry(file.getPath().substring(base.getPath().length() + 1));
...
voidzip(File directory, File file)
Recursively packs a directory into a zip file.
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(file));
try {
    zip(directory, directory.getPath().length() + 1, out);
} finally {
    out.close();
voidzip(File directory, File zipFile)
Zip the contents of a directory
ZipOutputStream zipStream = null;
try {
    zipStream = new ZipOutputStream(new FileOutputStream(zipFile));
    zipDir(directory.getPath(), directory.getPath(), zipStream);
} catch (IOException ioe) {
    throw ioe;
} finally {
    try {
...
voidzip(File directory, File zipFile)
Zip.
try {
    FileOutputStream os = new FileOutputStream(zipFile);
    ZipOutputStream zos = new ZipOutputStream(os);
    zipDirectory(directory, directory, zos);
    zos.close();
    os.close();
} catch (Exception e) {
    throw new RuntimeException(e);
...
voidzipDirectories(List directories, File baseDirectory, File zipFile)
zip Directories
zipDirectories(directories, baseDirectory, new FileOutputStream(zipFile), null);
voidzipDirectory(File baseDirectory, File output)
Create a ZIP archive of a directory.
try {
    FileOutputStream fos = new FileOutputStream(output);
    ZipOutputStream zos = new ZipOutputStream(fos);
    Deque<File> directories = new ArrayDeque<File>();
    if (baseDirectory.isDirectory()) {
        directories.add(baseDirectory);
        while (!directories.isEmpty()) {
            File directory = directories.poll();
...
FilezipDirectory(File dir, boolean includeDirInZip, boolean includeHidden)
create a zip file of the contents of the folder, optionally including the folder itself.
return zipDirectory(dir, includeDirInZip, includeHidden, null);
booleanzipDirectory(File dir, File zipFile)
Zip a directory and its subdirectories, preserving the name of the root directory (dir) in all paths in the zip file.
return zipDirectory(dir, zipFile, false);
voidzipDirectory(File dir, String base, ZipOutputStream zout)
zip Directory
File[] files = dir.listFiles();
base += dir.getName() + "/";
if (files.length > 0) {
    for (File file : files) {
        if (file.isDirectory()) {
            zipDirectory(file, base, zout);
        } else {
            zipOneFile(file, base, zout);
...