static public void zipFolder ( String srcFolder , String destZipFile , boolean addBaseFolder ) throws IOException { if ( new File ( srcFolder ) . isDirectory ( ) ) { try ( FileOutputStream fileWriter = new FileOutputStream ( destZipFile ) ; ZipOutputStream zip = new ZipOutputStream ( fileWriter ) ) { addFolderToZip ( "" , srcFolder , zip , addBaseFolder ) ; //$NON-NLS-1$ } } else { throw new IOException ( srcFolder + " is not a folder." ) ; } }
Compress a folder and its contents .