Java Zip Folder addFolderToZip(String folderPath, ZipOutputStream out)

Here you can find the source of addFolderToZip(String folderPath, ZipOutputStream out)

Description

Adds a new entry to the zip file corresponding to a new folder.

License

Apache License

Parameter

Parameter Description
folderPath the path to the folder relative to the zip file (e.g. "data", note that there is no tailing "/")
out the zip stream

Exception

Parameter Description
IOException if an IOException occurs

Declaration

public static void addFolderToZip(String folderPath, ZipOutputStream out)
        throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;

import java.util.zip.ZipEntry;

import java.util.zip.ZipOutputStream;

public class Main {
    /**//from  ww  w  .jav  a 2s  .  c  om
     * Adds a new entry to the zip file corresponding to a new folder.
     *
     * @param folderPath the path to the folder relative to the zip file (e.g.
     * "data", note that there is no tailing "/")
     * @param out the zip stream
     *
     * @throws IOException if an IOException occurs
     */
    public static void addFolderToZip(String folderPath, ZipOutputStream out)
            throws IOException {
        out.putNextEntry(new ZipEntry(folderPath + "/"));
    }
}

Related

  1. addFolderToZip(File folder, String parentFolderName, ZipOutputStream zip)
  2. addFolderToZip(String path, File srcFolder, ZipOutputStream zip)
  3. addFolderToZip(String path, File srcFolder, ZipOutputStream zip, String destZipFile)
  4. addFolderToZip(String path, String srcFolder, ZipOutputStream zip)
  5. addFolderToZip(String path, String srcFolder, ZipOutputStream zip)