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

booleanzip(String[] filename, String outname)
zip
boolean test = true;
try {
    BufferedInputStream origin = null;
    FileOutputStream dest = new FileOutputStream(outname);
    ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
    byte data[] = new byte[BUFFER];
    for (int i = 0; i < filename.length; i++) {
        File file = new File(filename[i]);
...
voidzip(String[] sFl, String sZip)
Zip array file
byte[] buf = new byte[1024];
try {
    ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(sZip));
    for (String s : sFl) {
        FileInputStream in = new FileInputStream(s);
        ZipEntry ze = new ZipEntry(s);
        zout.putNextEntry(ze);
        int len;
...
voidzip(String[] sourceFiles, String zipFile, String directory)
zip
try {
    zipFile = directory + File.separatorChar + zipFile;
    byte[] buffer = new byte[65535];
    int progress = 0;
    FileOutputStream fileOutputStream = new FileOutputStream(zipFile);
    ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream);
    for (int i = 0; i < sourceFiles.length; i++) {
        sourceFiles[i] = directory + File.separatorChar + sourceFiles[i];
...
voidzip(String[] srcFiles, String dstFile, String comment)
zip
if (srcFiles.length == 0) {
    return;
File fileDst = new File(dstFile);
File parentDir = fileDst.getParentFile();
if (!parentDir.exists()) {
    parentDir.mkdirs();
if (fileDst.exists()) {
    fileDst.delete();
fileDst.createNewFile();
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(fileDst));
zos.setMethod(ZipOutputStream.DEFLATED);
if (comment != null) {
    zos.setComment(comment);
DataOutputStream dos = new DataOutputStream(zos);
for (int i = 0; i < srcFiles.length; i++) {
    String entryPath = srcFiles[i];
    zos.putNextEntry(new ZipEntry(entryPath));
    File fileEntry = new File(entryPath);
    FileInputStream fis = new FileInputStream(fileEntry);
    byte[] buff = new byte[8192];
    int len = 0;
    while (true) {
        len = fis.read(buff);
        if (len == -1 || len == 0) {
            break;
        dos.write(buff, 0, len);
    zos.closeEntry();
    fis.close();
dos.close();
zos.close();
voidzipFileList(List files, File destinationDir)

GZIP the specified list of files.

for (File source : files) {
    File dest = new File(destinationDir, source.getName() + ".gz");
    zipFile(source, dest);
voidzipFiles(ArrayList files, String destZipFile)
zip Files
if (files.size() > 0) {
    ZipOutputStream zip = null;
    FileOutputStream fileWriter = null;
    fileWriter = new FileOutputStream(destZipFile);
    zip = new ZipOutputStream(fileWriter);
    for (File f : files) {
        addFileToZip("", f.getAbsolutePath(), zip);
    zip.flush();
    zip.close();
voidzipFiles(Collection resFileList, File zipFile)
zip Files
ZipOutputStream zipout = new ZipOutputStream(
        new BufferedOutputStream(new FileOutputStream(zipFile), BUFF_SIZE));
for (File resFile : resFileList) {
    zipFile(resFile, zipout, "");
zipout.close();
voidzipFiles(File file, JarOutputStream jos, String pathName)
zip Files
String fileName = pathName + file.getName();
if (file.isDirectory()) {
    fileName = fileName + "/";
    jos.putNextEntry(new JarEntry(fileName));
    String fileNames[] = file.list();
    if (fileNames != null) {
        for (int i = 0; i < fileNames.length; i++) {
            zipFiles(new File(file, fileNames[i]), jos, fileName);
...
voidzipFiles(File output, File root, List fileList)
zip Files
try {
    FileOutputStream fos = new FileOutputStream(output);
    ZipOutputStream zos = new ZipOutputStream(fos);
    for (File file : fileList) {
        if (file.isFile()) {
            addFileToZip(root, file, zos);
    zos.close();
    fos.close();
} catch (IOException e) {
    throw new RuntimeException("Unable to write zip file.", e);
voidzipFiles(File rootDir, File currDir, ZipOutputStream zos)
zip Files
if (currDir.isDirectory()) {
    final File[] files = currDir.listFiles();
    for (int i = 0; i < files.length; i++) {
        zipFiles(rootDir, files[i], zos);
} else {
    final String strAbsPath = currDir.getPath();
    final String strZipEntryName = strAbsPath.substring(rootDir.getPath().length() + 1,
...