Here you can find the source of writeFile(File file, byte[] buffer, ZipOutputStream zos)
private static void writeFile(File file, byte[] buffer, ZipOutputStream zos)
//package com.java2s; /**/*from w w w. ja v a2s.co m*/ * Copyright (c) 2013, Robert Cherry * All rights reserved. * * This file is part of the Faust Engine. * * The Faust Engine 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. * * The Faust Engine 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 * the Faust Engine. If not, see <http://www.gnu.org/licenses/>. */ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class Main { private static void writeFile(File file, byte[] buffer, ZipOutputStream zos) { try { try (FileInputStream fis = new FileInputStream(file)) { ZipEntry entry = new ZipEntry(file.getName()); // Place the entry zos.putNextEntry(entry); // int len; // Write to zipped file while ((len = fis.read(buffer)) > 0) { zos.write(buffer, 0, len); } // fis.close(); } } catch (IOException ioe) { // Throw an error eventually } } }