public static void zip ( final File aFileSystemDir , final File aOutputZipFile , final FilenameFilter aIncludesFilter , final File ... aIncludesFileList ) throws FileNotFoundException , IOException { final ZipOutputStream zipFileStream = new ZipOutputStream ( new FileOutputStream ( aOutputZipFile ) ) ; final String parentDirPath = aFileSystemDir . getParentFile ( ) . getAbsolutePath ( ) ; dirToZip ( aFileSystemDir , parentDirPath , aIncludesFilter , zipFileStream ) ; // Supplied additional files are just written into the root folder of the package for ( final File file : aIncludesFileList ) { final String path = File . separator + aFileSystemDir . getName ( ) + File . separator + file . getName ( ) ; final ZipEntry entry = new ZipEntry ( path ) ; final FileInputStream inFileStream = new FileInputStream ( file ) ; zipFileStream . putNextEntry ( entry ) ; IOUtils . copyStream ( inFileStream , zipFileStream ) ; IOUtils . closeQuietly ( inFileStream ) ; } IOUtils . closeQuietly ( zipFileStream ) ; }
Recursively zip up a file system directory .