Get a {@link ZipFile} entry as a string.
549353
public static String entryAsString(final ZipFile file, ZipEntry entry, Charset charset)
      throws IOException {
    return new ZipEntryByteSource(file, entry).asCharSource(charset).read();
  }
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);
		}
	}
95294
public static void pack(ZipEntrySource[] entries, File zip) {
    if (log.isDebugEnabled()) {
      log.debug("Creating '{}' from {}.", zip, Arrays.asList(entries));
    }

    OutputStream out = null;
    try {
      out = new BufferedOutputStream(new FileOutputStream(zip));
      pack(entries, out, true);
    }
    catch (IOException e) {
      throw ZipExceptionUtil.rethrow(e);
    }
    finally {
      IOUtils.closeQuietly(out);
    }
  }
809067
public static void extractFile(File zipFile,
                                   String entryName,
                                   File destination) throws IOException {
        ZipFile zip = new ZipFile(zipFile);

        try {
            ZipEntry entry = zip.getEntry(entryName);

            if (entry != null) {
                // Get an input stream for the entry.
                InputStream entryStream = zip.getInputStream(entry);
                try {
                    // Create the output file
                    File parent = destination.getParentFile();
                    if (parent != null) {
                        parent.mkdirs();
                    }

                    FileOutputStream file = new FileOutputStream(destination);

                    try {
                        // Allocate a buffer for reading the entry data.
                        byte[] data = new byte[BUFFER];
                        int bytesRead;

                        // Read the entry data and write it to the output file.
                        while ((bytesRead = entryStream.read(data)) != -1) {
                            file.write(data, 0, bytesRead);
                        }
                    } finally {
                        file.close();
                    }
                } finally {
                    entryStream.close();
                }
            } else {
                throw new IOException(zipFile.getName() + " does not contain: "
                        + entryName);
            }
        } finally {
            zip.close();
        }
    }
1290736
public static Map<String, Object> get(File packageFile) throws IOException {
    ZipFile zipFile = null;
    try {
      zipFile = new ZipFile(packageFile);
      ZipArchiveEntry entry = zipFile.getEntry(ZIP_ENTRY_PROPERTIES);
      if (entry != null && !entry.isDirectory()) {
        Map<String, Object> props = getPackageProperties(zipFile, entry);
        return new TreeMap<>(transformPropertyTypes(props));
      }
      return Collections.emptyMap();
    }
    finally {
      IOUtils.closeQuietly(zipFile);
    }
  }
667194
public static InputStream getResourceInputStreamForZip(ZipFile zipFile,
            String entryName) {
        try {
            return zipFile.getInputStream(zipFile.getEntry(entryName));
        } catch (Exception e) {
            return JMExceptionManager.handleExceptionAndReturnNull(log, e,
                    "newZipFile", zipFile, entryName);
        }
    }
765888
@Override
	public String getZipCode() {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 5; i++) {
			sb.append(random.nextInt(10));
		}
		return sb.toString();
	}
119033
private String asString() {
        try {
            return IOUtils.toString(asInputStream());
        } catch (IOException e) {
            throw new RuntimeException("Could not read from file '" + path + "'.", e);
        }
    }
154259
public static List<String> unzip(final File zipFile, final String destination) {
    return unzip(zipFile, destination, null);
  }
1229735
def get_contents_from_zip zip_file
        contents = {}
        Zip::File.open(zip_file) do |zip|
          zip.each_entry do |entry|
            entry.get_input_stream do |entryfile|
              contents[entry.name] = entryfile.read
            end
          end
        end
        return contents
      end
187155
public static List<String> unzip(final File zipFile, final String destination, String encoding) {
    List<String> fileNames = CollectUtils.newArrayList();
    String dest = destination;
    if (!destination.endsWith(File.separator)) {
      dest = destination + File.separator;
    }
    ZipFile file;
    try {
      file = null;
      if (null == encoding) file = new ZipFile(zipFile);
      else file = new ZipFile(zipFile, encoding);
      Enumeration<ZipArchiveEntry> en = file.getEntries();
      ZipArchiveEntry ze = null;
      while (en.hasMoreElements()) {
        ze = en.nextElement();
        File f = new File(dest, ze.getName());
        if (ze.isDirectory()) {
          f.mkdirs();
          continue;
        } else {
          f.getParentFile().mkdirs();
          InputStream is = file.getInputStream(ze);
          OutputStream os = new FileOutputStream(f);
          IOs.copy(is, os);
          is.close();
          os.close();
          fileNames.add(f.getAbsolutePath());
        }
      }
      file.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return fileNames;
  }
1083728
public static File zip(File zipFile, String path, InputStream in) throws UtilException {
		return zip(zipFile, path, in, DEFAULT_CHARSET);
	}
114522
public static void unzip(String jarFile, Path destination) throws IOException {
        Map<String, String> zipProperties = new HashMap<>();
        /* We want to read an existing ZIP File, so we set this to false */
        zipProperties.put("create", "false");
        zipProperties.put("encoding", "UTF-8");
        URI zipFile = URI.create("jar:" + jarFile);

        try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, zipProperties)) {
            Path rootPath = zipfs.getPath("/");
            Files.walkFileTree(rootPath, new SimpleFileVisitor<Path>() {
                @Override
                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                    Path targetPath = destination.resolve(rootPath.relativize(dir).toString());
                    if (!Files.exists(targetPath)) {
                        Files.createDirectory(targetPath);
                    }
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                    Files.copy(file, destination.resolve(rootPath.relativize(file).toString()), StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
                    return FileVisitResult.CONTINUE;
                }
            });
        }
    }
265264
public static List<String> readLinesForZip(String zipFilePathOrClasspath,
            String entryName) {
        return JMInputStream.readLines(
                getResourceInputStreamForZip(zipFilePathOrClasspath,
                        entryName));
    }
397695
@SuppressWarnings("unchecked")
	public static byte[] unzipFileBytes(File zipFile, Charset charset, String name) {
		ZipFile zipFileObj = null;
		try {
			zipFileObj = new ZipFile(zipFile, charset);
			final Enumeration<ZipEntry> em = (Enumeration<ZipEntry>) zipFileObj.entries();
			ZipEntry zipEntry = null;
			while (em.hasMoreElements()) {
				zipEntry = em.nextElement();
				if (zipEntry.isDirectory()) {
					continue;
				} else if (name.equals(zipEntry.getName())) {
					return IoUtil.readBytes(zipFileObj.getInputStream(zipEntry));
				}
			}
		} catch (IOException e) {
			throw new UtilException(e);
		} finally {
			IoUtil.close(zipFileObj);
		}
		return null;
	}
602471
public void addFile(String zipEntry, ByteArrayOutputStream baos) throws IOException {
		addFile(zipEntry, baos.toByteArray());
	}
1094585
public void addFile(String zipEntry, File file) throws IOException {
		String zipEntryName = Strings.isValid(zipEntry) ? zipEntry : file.getName();
		logger.debug("adding '{}' as '{}'", file.getName(), zipEntryName);
		try(InputStream input = new FileInputStream(file)) {
			addFile(zipEntryName, input);
		}
	}