Java Utililty Methods Zip File

List of utility methods to do Zip File

Description

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

Method

voidzip(File destination, File... files)
Zips a set of files in one file.
BufferedInputStream origin = null;
FileOutputStream dest = new FileOutputStream(destination);
try (ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest))) {
    byte data[] = new byte[BUFFER];
    for (int i = 0; i < files.length; i++) {
        FileInputStream fi = new FileInputStream(files[i]);
        origin = new BufferedInputStream(fi, BUFFER);
        ZipEntry entry = new ZipEntry(files[i].getName());
...
Filezip(File f, File destfile)
zip
java.io.BufferedOutputStream out = null;
ZipOutputStream zipOut = null;
try {
    out = new BufferedOutputStream(new FileOutputStream(destfile));
    zipOut = new ZipOutputStream(out);
    String basePath;
    if (f.isDirectory())
        basePath = f.getPath();
...
voidzip(File f, File out)
Creates ZIP of the file.
try (FileOutputStream fos = new FileOutputStream(out);
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        ZipOutputStream zos = new ZipOutputStream(bos)) {
    addToZip(f, f.getAbsolutePath().length(), zos, new byte[4096]);
voidzip(File file, File output)
zip
FileOutputStream outputStream = new FileOutputStream(output);
ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
String rootDirectory;
if (file.isDirectory()) {
    rootDirectory = file.getPath();
} else {
    rootDirectory = file.getParentFile().getPath();
zip(file, rootDirectory, zipOutputStream);
zipOutputStream.close();
voidzip(File file, File zip)
zip
ZipOutputStream zos = null;
try {
    String name = file.getName();
    zos = new ZipOutputStream(new FileOutputStream(zip));
    ZipEntry entry = new ZipEntry(name);
    zos.putNextEntry(entry);
    FileInputStream fis = null;
    try {
...
Filezip(File file, String dest)
zip
File zippedFile = new File(dest + "/" + file.getName() + ".zip");
try {
    FileOutputStream ops = new FileOutputStream(zippedFile);
    ZipOutputStream zos = new ZipOutputStream(ops);
    zip(file, zos, "");
    zos.close();
} catch (FileNotFoundException fnfex) {
    fnfex.printStackTrace();
...
voidzip(File fromFile, File toFile)
Zip the sourceFile into toFile.
zip(new FileInputStream(fromFile), toFile);
voidzip(File input, File output)
zip
byte[] block = new byte[16384];
FileInputStream fis = null;
FileOutputStream fos = null;
ZipOutputStream zos = null;
try {
    fis = new FileInputStream(input);
    fos = new FileOutputStream(output);
    zos = new ZipOutputStream(fos);
...
voidzip(File input, File outputZip)
zip
zip(input, new FileOutputStream(outputZip), false, null);
voidzip(File inputDirectory, File zippedFile, FileFilter filter)
zip
int BUFFER = 2048;
try {
    BufferedInputStream origin = null;
    FileOutputStream dest = new FileOutputStream(zippedFile);
    ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
    byte data[] = new byte[BUFFER];
    File files[];
    if (filter != null) {
...