Here you can find the source of zipFile(ZipOutputStream zipOut, String path, File file)
public static void zipFile(ZipOutputStream zipOut, String path, File file) throws IOException
//package com.java2s; import java.io.*; import java.util.zip.*; public class Main { public static void zipFile(ZipOutputStream zipOut, String path, File file) throws IOException { if (!file.canRead()) { System.out.println("Cannot read " + file.getCanonicalPath() + " (maybe because of permissions)"); return; }//from ww w . j av a 2 s .c om System.out.println("Compressing " + file.getName()); zipOut.putNextEntry(new ZipEntry(file.getName())); FileInputStream fis = new FileInputStream(file); byte[] buffer = new byte[4092]; int byteCount = 0; while ((byteCount = fis.read(buffer)) != -1) { zipOut.write(buffer, 0, byteCount); System.out.print('.'); System.out.flush(); } System.out.println(); fis.close(); zipOut.closeEntry(); } }