public static void zipFiles(File zip,File... files) throws IOException {
  try (BufferedOutputStream bufferedOut=new BufferedOutputStream(new FileOutputStream(zip))){
    zipFiles(bufferedOut,files);
  }
 }

public static void zipFiles ( File zip , File ... files ) throws IOException { try ( BufferedOutputStream bufferedOut = new BufferedOutputStream ( new FileOutputStream ( zip ) ) ) { zipFiles ( bufferedOut , files ) ; } }
create an output zip stream and add each file to that stream . directory files are added recursively . the contents of the zip are written to the given file .
