Java ZipEntry Add addZipEntry(String pathName, byte[] contents, ZipOutputStream zos)

Here you can find the source of addZipEntry(String pathName, byte[] contents, ZipOutputStream zos)

Description

Adds the zip entry.

License

Open Source License

Parameter

Parameter Description
pathName the path name
contents the contents
zos the zos

Exception

Parameter Description
IOException Signals that an I/O exception has occurred.

Declaration

public static void addZipEntry(String pathName, byte[] contents,
        ZipOutputStream zos) throws IOException 

Method Source Code

//package com.java2s;

import java.io.IOException;
import java.util.zip.ZipEntry;

import java.util.zip.ZipOutputStream;

public class Main {
    /**/*w  ww  . jav a2s. c om*/
     * Adds the zip entry.
     *
     * @param pathName the path name
     * @param contents the contents
     * @param zos the zos
     * @throws IOException Signals that an I/O exception has occurred.
     */
    public static void addZipEntry(String pathName, byte[] contents,
            ZipOutputStream zos) throws IOException {
        ZipEntry entry = new ZipEntry(pathName);
        entry.setSize(contents.length);
        zos.putNextEntry(entry);
        zos.write(contents);
        zos.closeEntry();
    }
}

Related

  1. addZipEntry(ZipOutputStream zipOut, File file, String prefix)
  2. addZipEntry(ZipOutputStream zipOutputStream, File entryFile, String parentPath)
  3. addZipEntry(ZipOutputStream zos, File fileToZip, File baseFolder)
  4. addZipEntryFromStream(InputStream is, ZipOutputStream os, String filename)