public static boolean zipFolder ( File folder , String fileName ) { boolean success = false ; if ( ! folder . isDirectory ( ) ) { return false ; } if ( fileName == null ) { fileName = folder . getAbsolutePath ( ) + ZIP_EXT ; } ZipArchiveOutputStream zipOutput = null ; try { zipOutput = new ZipArchiveOutputStream ( new File ( fileName ) ) ; success = addFolderContentToZip ( folder , zipOutput , "" ) ; zipOutput . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; return false ; } finally { try { if ( zipOutput != null ) { zipOutput . close ( ) ; } } catch ( IOException e ) { } } return success ; }
Utility function to zip the content of an entire folder but not the folder itself .