Java Zip Directory addDirectoryToZip(ZipOutputStream zipOutputStream, String dirName)

Here you can find the source of addDirectoryToZip(ZipOutputStream zipOutputStream, String dirName)

Description

Adds a directory to a .zip file

License

Apache License

Parameter

Parameter Description
zipOutputStream instance of ZipOutputStream
dirName Directory name you want to add to the .zip file

Exception

Parameter Description
IOException an exception

Declaration

public static void addDirectoryToZip(ZipOutputStream zipOutputStream, String dirName) 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  w w w  . ja  v  a 2  s.  co m*/
     * Adds a directory to a .zip file
     *
     * @param zipOutputStream instance of ZipOutputStream
     * @param dirName         Directory name you want to add to the .zip file
     * @throws IOException
     */
    public static void addDirectoryToZip(ZipOutputStream zipOutputStream, String dirName) throws IOException {
        zipOutputStream.putNextEntry(new ZipEntry(dirName));
        zipOutputStream.closeEntry();
    }
}

Related

  1. addDirectoryToZip(File directory, File base, String dirPrefix, ZipOutputStream zos)
  2. addDirectoryToZip(ZipOutputStream out, File dir, String prefix)
  3. addDirectoryToZip(ZipOutputStream zipOutputStream, File dirToZip, String basePath, File fileToExclude)
  4. addDirToArchive(ZipOutputStream zop, File srcFile)
  5. addDirToArchive(ZipOutputStream zos, File srcFile)
  6. addDirToArchive(ZipOutputStream zos, String path, File initialDir)
  7. zip(File dir, File base, ZipOutputStream out)