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.");
        }
    }
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 ) ; } } else { throw new IOException ( srcFolder + " is not a folder." ) ; } }
Compress a folder and its contents.

@param srcFolder path to the folder to be compressed.
@param destZipFile path to the final output zip file.
@param addBaseFolder flag to decide whether to add also the provided base (srcFolder) folder or not.
@throws IOException