Here you can find the source of zipFile(ZipOutputStream zos, BufferedOutputStream out, File destPath, String originalPath)
private static void zipFile(ZipOutputStream zos, BufferedOutputStream out, File destPath, String originalPath) throws IOException
//package com.java2s; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class Main { private static void zipFile(ZipOutputStream zos, BufferedOutputStream out, File destPath, String originalPath) throws IOException { BufferedReader in = new BufferedReader(new FileReader(destPath)); zos.putNextEntry(new ZipEntry(destPath.getAbsolutePath().substring(originalPath.length()))); int c;/*w ww . j a va 2 s .c o m*/ while ((c = in.read()) != -1) out.write(c); in.close(); } }