public static void zipFiles(List<File> files, OutputStream outputStream) throws IOException {
        ZipOutputStream zos = new ZipOutputStream(outputStream);

        for (File file : files) {
            if (file.isDirectory()) {   //if it's a folder
                addFolderToZip("", file, zos);
            } else {
                addFileToZip("", file, zos);
            }
        }

        zos.finish();
    }
public static void zipFiles ( List < File > files , OutputStream outputStream ) throws IOException { ZipOutputStream zos = new ZipOutputStream ( outputStream ) ; for ( File file : files ) { if ( file . isDirectory ( ) ) { addFolderToZip ( "" , file , zos ) ; } else { addFileToZip ( "" , file , zos ) ; } } zos . finish ( ) ; }
Zips a collection of files to a destination zip output stream.

@param files        A collection of files and directories
@param outputStream The output stream of the destination zip file
@throws FileNotFoundException
@throws IOException