Adds a file to the ZIP archive, given its content as an array of bytes.

@param zipEntry
name of the entry in the archive.
@param data
data bytes to be stored as file contents in the archive.
439745
public void addFile(String zipEntry, byte[] data) throws IOException  {
		stream.putNextEntry(new ZipEntry(zipEntry));
		stream.write(data);
	}
796591
public static void addEntry(File zip, String path, byte[] bytes, File destZip) {
    addEntry(zip, new ByteSource(path, bytes), destZip);
  }
352212
private ByteArrayOutputStream getZipEntryContent(
            ZipInputStream zipStream,
            ZipEntry entry ) throws IOException {
        try (ByteArrayOutputStream content =
                new ByteArrayOutputStream()) {
            byte[] bytes = new byte[(int) entry.getSize()];
            int read;
            while ((read = zipStream.read(bytes, 0, bytes.length)) != -1) {
                content.write(bytes, 0, read);
            }
            return content;
        }
    }
777338
public void setData(byte[] data) {
        byte[] copy = new byte[data.length];
        System.arraycopy(data, 0, copy, 0, data.length);
        this.data = copy;
    }
1162083
private void addDirectoryToZip(File topDirectory, File directory, ZipOutputStream out) throws IOException {
    Path top = Paths.get(topDirectory.getAbsolutePath());

    File[] files = directory.listFiles();
    byte[] buffer = new byte[BUFFER_SIZE];

    for (int i = 0; i < files.length; i++) {
      Path entry = Paths.get(files[i].getAbsolutePath());
      Path relative = top.relativize(entry);
      String entryName = relative.toString();
      if (files[i].isDirectory()) {
        entryName += FILE_SEPARATOR;
      }

      out.putNextEntry(new ZipEntry(entryName.replace("\\", "/")));

      if (!files[i].isDirectory()) {
        try (FileInputStream in = new FileInputStream(files[i])) {
          int bytesRead;
          while ((bytesRead = in.read(buffer)) != -1) {
            out.write(buffer, 0, bytesRead);
          }
        }
        out.closeEntry();
      }

      if (files[i].isDirectory()) {
        addDirectoryToZip(topDirectory, files[i], out);
      }
    }
  }
908917
private void handleArchiveByFile(Predicate<String> filter, File archive, List<String> discoveredFiles)
    {
        try
        {
            try (ZipFile zip = new ZipFile(archive))
            {
                Enumeration<? extends ZipEntry> entries = zip.entries();
                
                while (entries.hasMoreElements())
                {
                    ZipEntry entry = entries.nextElement();
                    String name = entry.getName();
                    if (filter.accept(name))
                        discoveredFiles.add(name);
                }
            }
        }
        catch (IOException e)
        {
            throw new RuntimeException("Error handling file " + archive, e);
        }
    }
1009103
protected void addToZip(final String path, final byte[] data, final BuildData buildData) {
        buildData.getOutputFiles().put(path, data);
    }
1206874
public static boolean containsAnyEntry(File zip, String[] names) {
    ZipFile zf = null;
    try {
      zf = new ZipFile(zip);
      for (int i = 0; i < names.length; i++) {
        if (zf.getEntry(names[i]) != null) {
          return true;
        }
      }
      return false;
    }
    catch (IOException e) {
      throw ZipExceptionUtil.rethrow(e);
    }
    finally {
      closeQuietly(zf);
    }
  }
552385
def chunk_zip_entry(zipfile, name, chunksize=_CHUNKSIZE):
    

    with open_zip_entry(zipfile, name, mode='r') as stream:
        data = stream.read(chunksize)
        while data:
            yield data
            data = stream.read(chunksize)
941717
private void mapFilesInZip(String fileName) {
		File file = new File(fileName);
		fileCreationTimes.put(file, new Long(file.lastModified()));

		ZipFile zipfile;
		try {
			zipfile = new ZipFile(fileName);
		} catch (IOException ioe) {
			throw new NoClassDefFoundError("class location '" + fileName + "' can not be accessed by classloader: " + ioe);
		}
		Enumeration<? extends ZipEntry> e = zipfile.entries();
		while (e.hasMoreElements()) {
			ZipEntry entry = e.nextElement();
			if (!entry.isDirectory()) {
				mapClassResourceEntry(entry.getName(), fileName);
			}
		}
		try {
			zipfile.close();
		} catch (IOException ioe) {
			throw new NoClassDefFoundError("class fileName '" + fileName + "' can not be accessed by classloader: " + ioe);
		}
	}
763248
public void writeEntries(JarFile jarFile) throws IOException {
        Enumeration<JarEntry> entries = jarFile.entries();
        while (entries.hasMoreElements()) {
            JarEntry entry = entries.nextElement();
            ZipHeaderPeekInputStream inputStream = new ZipHeaderPeekInputStream(
                    jarFile.getInputStream(entry));
            try {
                if (inputStream.hasZipHeader() && entry.getMethod() != ZipEntry.STORED) {
                    new CrcAndSize(inputStream).setupStoredEntry(entry);
                    inputStream.close();
                    inputStream = new ZipHeaderPeekInputStream(
                            jarFile.getInputStream(entry));
                }
                EntryWriter entryWriter = new InputStreamEntryWriter(inputStream, true);
                writeEntry(entry, entryWriter);
            } finally {
                inputStream.close();
            }
        }
    }
1249062
@Override
    public T addAsLibrary(final Archive<?> archive) throws IllegalArgumentException {
        Validate.notNull(archive, "Archive must be specified");
        // Libraries are JARs, so add as ZIP
        return add(archive, getLibraryPath(), ZipExporter.class);
    }
534547
protected void addToZip(final String path, final String file, BuildData buildData) throws BuildProcessingException {
        try {
            buildData.getOutputFiles().put(path, file.getBytes(ENCODING));
        } catch (UnsupportedEncodingException e) {
            /* UTF-8 is a valid format so this should exception should never get thrown */
            throw new BuildProcessingException(e);
        }
    }
466623
public void add(final D data)
	{
		this.container.add(data);

		// if the size of data is known add the value to the task size
		if (data instanceof ISizeable) {
			this.byteSize += ((ISizeable) data).byteSize();
		}
	}
1286364
static void copyEntry(ZipEntry zipEntry, InputStream in, ZipOutputStream out) throws IOException {
    copyEntry(zipEntry, in, out, true);
  }
615064
public static void zipFiles(final ZipFile zipFile4j, final ZipParameters parameters,
		final List<File> toAdd) throws ZipException
	{
		for (final File element : toAdd)
		{
			zipFile4j.addFile(element, parameters);
		}
	}
105336
public static void addEntry(File zip, ZipEntrySource entry, File destZip) {
    addEntries(zip, new ZipEntrySource[] { entry }, destZip);
  }