Java Utililty Methods Zip Folder

List of utility methods to do Zip Folder

Description

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

Method

voidzipFolder(String srcFolder, String destZipFile)
zip Folder
ZipOutputStream zip = null;
FileOutputStream fileWriter = null;
fileWriter = new FileOutputStream(destZipFile);
zip = new ZipOutputStream(fileWriter);
addFolderToZip("", srcFolder, zip);
zip.flush();
zip.close();
voidzipFolder(String srcFolder, String destZipFile)
zip Folder
ZipOutputStream zip = null;
FileOutputStream fileWriter = null;
fileWriter = new FileOutputStream(destZipFile);
zip = new ZipOutputStream(fileWriter);
File f = new File(srcFolder);
File[] subFiles = f.listFiles();
for (int i = 0; i < subFiles.length; i++) {
    File subFile = subFiles[i];
...
voidzipFolder(String srcFolder, String destZipFile)
zip Folder
ZipOutputStream zip = null;
FileOutputStream fileWriter = null;
try {
    fileWriter = new FileOutputStream(destZipFile);
    zip = new ZipOutputStream(fileWriter);
} catch (Exception ex) {
    ex.printStackTrace();
    return;
...
voidzipFolder(String srcFolder, String destZipFile, boolean addBaseFolder)
Compress a folder and its contents.
if (new File(srcFolder).isDirectory()) {
    ZipOutputStream zip = null;
    FileOutputStream fileWriter = null;
    try {
        fileWriter = new FileOutputStream(destZipFile);
        zip = new ZipOutputStream(fileWriter);
        addFolderToZip("", srcFolder, zip, addBaseFolder); 
    } finally {
...
voidzipFolder(String srcFolderPath, String outputZipPath)
Zip folder
ZipOutputStream zip = null;
FileOutputStream fileWriter = null;
fileWriter = new FileOutputStream(outputZipPath);
zip = new ZipOutputStream(fileWriter);
addFolderToZip("", srcFolderPath, zip);
zip.flush();
zip.close();
voidzipFolder(ZipOutputStream zipOut, File folder, File root)
zip Folder
byte[] data = new byte[BUFFER_SIZE];
String prefix = root.getAbsolutePath();
for (File f : folder.listFiles()) {
    if (f.isDirectory()) {
        zipFolder(zipOut, f, root);
    } else {
        zipOut.putNextEntry(new ZipEntry(f.getAbsolutePath().substring(prefix.length())));
        FileInputStream in = new FileInputStream(f);
...
voidzipFolder2(ZipOutputStream zos, String folderName, String baseFolderName)
zip Folder
File f = new File(folderName);
if (f.exists()) {
    if (f.isDirectory()) {
        if (!folderName.equalsIgnoreCase(baseFolderName)) {
            String entryName = folderName.substring(baseFolderName.length(), folderName.length())
                    + File.separatorChar;
            ZipEntry ze = new ZipEntry(entryName);
            zos.putNextEntry(ze);
...