Here you can find the source of addDirectoryToZip(ZipOutputStream zipOutputStream, String dirName)
Parameter | Description |
---|---|
zipOutputStream | instance of ZipOutputStream |
dirName | Directory name you want to add to the .zip file |
Parameter | Description |
---|---|
IOException | an exception |
public static void addDirectoryToZip(ZipOutputStream zipOutputStream, String dirName) throws IOException
//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(); } }