Java Utililty Methods Zip File List

List of utility methods to do Zip File List

Description

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

Method

voidzip(Collection files, File zipFile)
zip
FileOutputStream fos = new FileOutputStream(zipFile);
try {
    BufferedOutputStream bos = new BufferedOutputStream(fos);
    try {
        ZipOutputStream zos = new ZipOutputStream(bos);
        try {
            for (Iterator i = files.iterator(); i.hasNext();) {
                File file = (File) i.next();
...
voidzip(File zipFile, File parentDir, File[] sources, char pathSeparator)
Recursively zips a set of root entries into a zipfile, compressing the contents.
String stripPath = (parentDir != null) ? parentDir.getPath() : "";
if (stripPath.length() > 0 && !stripPath.endsWith(File.separator)) {
    stripPath += File.separator;
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
out.setMethod(ZipOutputStream.DEFLATED);
try {
    for (File source : sources) {
...
voidzip(File zipFile, File[] files)
zip
try {
    BufferedInputStream origin = null;
    FileOutputStream dest = new FileOutputStream(zipFile);
    ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
    out.setMethod(ZipOutputStream.DEFLATED);
    byte data[] = new byte[BUFFER];
    for (int i = 0; i < files.length; i++) {
        FileInputStream fi = new FileInputStream(files[i]);
...
voidzip(File zipFile, File[] files)
zip
byte[] buffer = new byte[1024];
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))) {
    for (File file : files) {
        ZipEntry ze = new ZipEntry(file.getName());
        zos.putNextEntry(ze);
        try (FileInputStream in = new FileInputStream(file)) {
            int len;
            while ((len = in.read(buffer)) > 0) {
...
Filezip(File zipFile, List files)
zip
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
zip(out, files);
return zipFile;
voidzip(Iterable files, String baseFolderName, String toZipFile)
Zips the specified files, including directories and nested directories into the specified zip file.
ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(toZipFile));
if (files != null) {
    for (File file : files) {
        if (file.exists()) {
            if (file.isDirectory()) {
                addFolderToZip(file, baseFolderName, zip);
            } else {
                addFileToZip(file, baseFolderName, zip);
...
voidzip(List runtimeLibFiles, File saturnContainerDir, File zipFile)
zip
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile));
for (File file : runtimeLibFiles) {
    zip(file, "app" + fileSeparator + "lib", zos);
zos.close();
byte[]zip(List fileNames, List fileContents)
Zip files
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream out = new ZipOutputStream(baos);
for (int i = 0, size = fileNames.size(); i < size; i++) {
    String name = fileNames.get(i);
    byte[] content = fileContents.get(i);
    ZipEntry entry = new ZipEntry(name);
    entry.setSize(content.length);
    out.putNextEntry(entry);
...
voidzip(List fileNames, String outFileName)
zip
byte[] buf = new byte[1024];
try {
    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFileName));
    for (String fileName : fileNames) {
        FileInputStream in = new FileInputStream(fileName);
        out.putNextEntry(new ZipEntry(fileName));
        int len;
        while ((len = in.read(buf)) > 0) {
...
ZipOutputStreamzip(List srcFiles, OutputStream os)
zip
byte[] buffer = new byte[1024];
ZipOutputStream zos = new ZipOutputStream(os);
for (String f : srcFiles) {
    File srcFile = new File(f);
    FileInputStream fis = new FileInputStream(srcFile);
    zos.putNextEntry(new ZipEntry(srcFile.getName()));
    int length;
    while ((length = fis.read(buffer)) > 0) {
...