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

voidzipDirectory(File dir, String zipDirName)
zip Directory
try {
    filesListInDir = new ArrayList<String>();
    getFilesList(dir);
    FileOutputStream fos = new FileOutputStream(zipDirName);
    ZipOutputStream zos = new ZipOutputStream(fos);
    for (String filePath : filesListInDir) {
        ZipEntry ze = new ZipEntry(
                filePath.substring(dir.getAbsolutePath().length() + 1, filePath.length()));
...
voidzipDirectory(File directory, File zip)
zip Directory
FileOutputStream fos = new FileOutputStream(zip);
ZipOutputStream zos = new ZipOutputStream(fos);
zipArchive(directory, directory, zos);
zos.close();
fos.close();
voidzipDirectory(File directory, File zip)
This method converts a directory into a zip file
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zip));
zip(directory, directory, zos);
zos.close();
voidzipDirectory(File directory, File zipFile)
zip Directory
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
addDir(directory, directory, out);
out.close();
voidzipDirectory(File directory, File zipFile)
Zips a directory to a specified file.
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile));
try {
    zipDirectory(directory , directory, zos);
} finally {
    zos.close();
voidzipDirectory(File directory, File zipFile, Pattern exclusion)
Utility method to zip a directory hierarchy recursively into a single compressed file.
zipDirectory(directory, zipFile, new byte[BUFFER_SIZE], exclusion);
voidzipDirectory(File directory, ZipOutputStream zipout, final FilenameFilter filter)
Zips up the directory contents into the specified ZipOutputStream .
zipDirectory(directory, "", zipout, filter);
FilezipDirectory(File dirToZip, File outputDir, String fileName)
Zip the content of a directory.
if (!dirToZip.exists()) {
    throw new FileNotFoundException("Directory to zip " + dirToZip.getCanonicalPath() + " does not exist");
if (!outputDir.exists()) {
    throw new FileNotFoundException("Output directory " + outputDir.getCanonicalPath() + " does not exist");
File zipFile = new File(outputDir, fileName);
try (ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(zipFile));) {
...
voidzipDirectory(File folder, File outputFile)
zip Directory
ZipOutputStream zos = null;
try {
    zos = new ZipOutputStream(new FileOutputStream(outputFile));
    zip(folder, folder, zos);
    zos.close();
} catch (IOException ioException) {
    throw ioException;
} finally {
...
voidzipDirectory(File inputDirectory, File zipFile)
Zip compresses a directory.
FileOutputStream dest = new FileOutputStream(zipFile);
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
constructZip(inputDirectory, out, "");
out.close();