Here you can find the source of zipFile(ZipOutputStream zos, File file, String requestName, byte[] buf)
public static String zipFile(ZipOutputStream zos, File file, String requestName, byte[] buf) throws IOException
//package com.java2s; /*//from ww w. jav a2 s . c o m SongScribe song notation program Copyright (C) 2006 Csaba Kavai This file is part of SongScribe. SongScribe is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. SongScribe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Created on Aug 6, 2006 */ import java.io.*; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class Main { public static String zipFile(ZipOutputStream zos, File file, String requestName, byte[] buf) throws IOException { String fileName = requestName == null ? file.getName() : requestName; zos.putNextEntry(new ZipEntry(fileName)); FileInputStream fis = new FileInputStream(file); int read; while ((read = fis.read(buf)) > 0) { zos.write(buf, 0, read); } fis.close(); return fileName; } }