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

voidzipDir(File dir, String relativePath, ZipOutputStream zos)
Zips a local directory, recursively, into a ZIP stream.
zipDir(dir, relativePath, zos, true);
zos.close();
voidzipDir(File dir, String relativePath, ZipOutputStream zos, boolean start)
zip Dir
String[] dirList = dir.list();
for (String aDirList : dirList) {
    File f = new File(dir, aDirList);
    if (!f.isHidden()) {
        if (f.isDirectory()) {
            if (!start) {
                ZipEntry dirEntry = new ZipEntry(relativePath + f.getName() + "/");
                zos.putNextEntry(dirEntry);
...
voidzipDir(File dir, ZipOutputStream zos, String prefix)
Recursively zips all files in "dir" and its subdirectories into the given ZipOutputStream "zos" using the given path prefix for their names
File[] entries = dir.listFiles();
for (int i = 0; i < entries.length; i++) {
    if (entries[i].isDirectory()) {
        ZipEntry zi = new ZipEntry(prefix + "/" + entries[i].getName() + "/");
        try {
            zos.putNextEntry(zi);
            zos.closeEntry();
        } catch (IOException ioex) {
...
voidzipDir(File directory, ZipOutputStream zos, String path, Set exclusions)
Zip up a directory path
File[] dirList = directory.listFiles();
byte[] readBuffer = new byte[8192];
int bytesIn;
assert dirList != null;
for (File f : dirList) {
    if (f.isDirectory()) {
        String prefix = path + f.getName() + "/";
        zos.putNextEntry(new ZipEntry(prefix));
...
voidzipDir(File sourceDir, File destFile)
zip Dir
FileOutputStream fos = new FileOutputStream(destFile);
ZipOutputStream zos = new ZipOutputStream(fos);
zipDir(sourceDir, destFile, zos);
zos.close();
voidzipDir(File zipDir, ZipOutputStream zos, boolean recurse)
Utility to compress the contents of a Directory to a ZipOutputStream, if necessary recursing
String[] dirList = zipDir.list();
byte[] readBuffer = new byte[2156];
int bytesIn = 0;
for (String element : dirList) {
    File f = new File(zipDir, element);
    if (f.isDirectory()) {
        if (recurse)
            zipDir(f, zos, recurse);
...
voidzipDir(File zipDir, ZipOutputStream zos, String archiveSourceDir)
zip Dir
String[] dirList = zipDir.list();
byte[] readBuffer = new byte[40960];
int bytesIn;
if (dirList != null) {
    for (String aDirList : dirList) {
        File f = new File(zipDir, aDirList);
        zos.putNextEntry(new ZipEntry(getZipEntryPath(f, archiveSourceDir)));
        if (f.isDirectory()) {
...
voidzipDir(File zipDir, ZipOutputStream zos, String basePath)
zip Dir
FileInputStream fis = null;
try {
    File[] dirList = zipDir.listFiles();
    byte[] readBuffer = new byte[BUFFER_SIZE];
    int bytesIn = 0;
    for (int i = 0; i < dirList.length; i++) {
        File f = dirList[i];
        if (f.isDirectory()) {
...
voidzipDir(File zipDir, ZipOutputStream zos, String name)
zip Dir
if (name.endsWith(File.separator))
    name = name.substring(0, name.length() - File.separator.length());
if (!name.endsWith(ZIP_FILE_SEPARATOR))
    name = name + ZIP_FILE_SEPARATOR;
File[] dirList = zipDir.listFiles();
if (dirList.length == 0) { 
    if (DEBUG)
        System.out.println("Add empty entry for directory : " + name);
...
voidzipDir(File zipFile, File dir, boolean includeRoot)
zip Dir
if (!dir.isDirectory()) {
    return;
ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(zipFile));
try {
    if (includeRoot) {
        _zip(dir.getName(), dir, zip);
    } else {
...