Open the ZipEntry as a ByteBuffer slice. Only call this method if {@link #canGetAsSlice()} returned true.

@return the ZipEntry as a ByteBuffer.
@throws IOException
If an I/O exception occurs.
@throws InterruptedException
If the thread was interrupted.
161759
public ByteBuffer getAsSlice() throws IOException, InterruptedException {
        // Check the file is STORED and resides in only one chunk
        if (!canGetAsSlice()) {
            throw new IllegalArgumentException("Cannot open zip entry as a slice");
        }
        // Fetch the ByteBuffer for the applicable chunk
        final long dataStartOffsetWithinPhysicalZipFile = getEntryDataStartOffsetWithinPhysicalZipFile();
        final int chunkIdx = (int) (dataStartOffsetWithinPhysicalZipFile / FileUtils.MAX_BUFFER_SIZE);
        final long chunkStart = chunkIdx * (long) FileUtils.MAX_BUFFER_SIZE;
        final ByteBuffer dupdBuf = parentLogicalZipFile.physicalZipFile.getByteBuffer(chunkIdx).duplicate();
        // Create and return a slice on the chunk ByteBuffer that contains only this zip entry
        // N.B. the cast to Buffer is necessary, see:
        // https://github.com/plasma-umass/doppio/issues/497#issuecomment-334740243
        // https://github.com/classgraph/classgraph/issues/284#issuecomment-443612800
        ((Buffer) dupdBuf).position((int) (dataStartOffsetWithinPhysicalZipFile - chunkStart));
        ((Buffer) dupdBuf).limit((int) (dataStartOffsetWithinPhysicalZipFile + uncompressedSize - chunkStart));
        return dupdBuf.slice();
    }
678579
public static boolean unzipFileOrFolder(File zipFile, String unzippedFolder){
		InputStream is;
		ArchiveInputStream in = null;
		OutputStream out  = null;
		
		if(!zipFile.isFile()){
			return false;
		}
		
		if(unzippedFolder == null){
			unzippedFolder = FilenameUtils.removeExtension(zipFile.getAbsolutePath());
		}
		try {
			is = new FileInputStream(zipFile);
			new File(unzippedFolder).mkdir();
			
			in = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.ZIP, is);
			
			ZipArchiveEntry entry = (ZipArchiveEntry)in.getNextEntry();
			while(entry != null){
				if(entry.isDirectory()){
					new File(unzippedFolder,entry.getName()).mkdir();
				}
				else{
					out = new FileOutputStream(new File(unzippedFolder, entry.getName()));
					IOUtils.copy(in, out);
					out.close();
					out = null;
				}
				entry = (ZipArchiveEntry)in.getNextEntry();
			}	
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			return false;
		} catch (ArchiveException e) {
			e.printStackTrace();
			return false;
		} catch (IOException e) {
			e.printStackTrace();
			return false;
		}
		finally{
			if(out != null){
				try {
					out.close();
				} catch (IOException e) {}
			}
			if(in != null){
				try {
					in.close();
				} catch (IOException e) {}
			}
		}
		return true;
	}
1018199
public static void unZip(File inFile, File unzipDir) throws IOException {
    Enumeration<? extends ZipEntry> entries;
    ZipFile zipFile = new ZipFile(inFile);

    try {
      entries = zipFile.entries();
      while (entries.hasMoreElements()) {
        ZipEntry entry = entries.nextElement();
        if (!entry.isDirectory()) {
          InputStream in = zipFile.getInputStream(entry);
          try {
            File file = new File(unzipDir, entry.getName());
            if (!file.getParentFile().mkdirs()) {
              if (!file.getParentFile().isDirectory()) {
                throw new IOException("Mkdirs failed to create " +
                                      file.getParentFile().toString());
              }
            }
            OutputStream out = new FileOutputStream(file);
            try {
              byte[] buffer = new byte[8192];
              int i;
              while ((i = in.read(buffer)) != -1) {
                out.write(buffer, 0, i);
              }
            } finally {
              out.close();
            }
          } finally {
            in.close();
          }
        }
      }
    } finally {
      zipFile.close();
    }
  }
795072
@Nullable
  public static byte[] toByteArray(@Nonnull final ZipFile zipFile, @Nonnull final String path) throws IOException {
    final InputStream in = findInputStreamForResource(zipFile, path);

    byte[] result = null;

    if (in != null) {
      try {
        result = IOUtils.toByteArray(in);
      } finally {
        IOUtils.closeQuietly(in);
      }
    }

    return result;
  }
444783
public Optional<ZipErrorCodes> zip()
	{
		try (FileOutputStream fos = new FileOutputStream(this.zipFile);
			ZipOutputStream zos = new ZipOutputStream(fos);)
		{

			if (!this.directoryToZip.exists())
			{
				return Optional.of(ZipErrorCodes.DIRECTORY_TO_ZIP_DOES_NOT_EXIST);
			}
			if (!this.zipFile.exists())
			{
				return Optional.of(ZipErrorCodes.ZIP_FILE_DOES_NOT_EXIST);
			}
			if (0 < this.zipLevel)
			{
				zos.setLevel(this.zipLevel);
			}
			else
			{
				zos.setLevel(9);
			}
			if (null != this.zipFileComment)
			{
				zos.setComment(this.zipFileComment);
			}
			if (0 < this.compressionMethod)
			{
				zos.setMethod(this.compressionMethod);
			}
			this.zipFiles(this.directoryToZip, zos);
			zos.flush();
			zos.finish();
			fos.flush();
		}
		catch (IOException e)
		{
			log.log(Level.SEVERE, e.getLocalizedMessage(), e);
			return Optional.of(ZipErrorCodes.IO_ERROR);
		}
		return Optional.empty();
	}
1138351
public static boolean transformEntry(final File zip, final ZipEntryTransformerEntry entry) {
    return operateInPlace(zip, new InPlaceAction() {
      public boolean act(File tmpFile) {
        return transformEntry(zip, entry, tmpFile);
      }
    });
  }
1093923
public final Mono<ByteBuffer> asByteBuffer() {
		return handle((bb, sink) -> {
			try {
				sink.next(bb.nioBuffer());
			}
			catch (IllegalReferenceCountException e) {
				sink.complete();
			}
		});
	}
1215917
private boolean isZip(JarEntry entry) throws IOException {
        try (InputStream entryInputStream = sourceFatJar.getInputStream(entry)) {
            try (ZipInputStream zipInputStream = new ZipInputStream(entryInputStream)) {
                ZipEntry ze = zipInputStream.getNextEntry();
                if (ze == null) {
                    return false;
                }
                return true;
            }
        }
    }
370684
public static <K extends WritableComparable, V extends Writable>
  Writable getEntry(MapFile.Reader[] readers,
                                  Partitioner<K, V> partitioner,
                                  K key,
                                  V value) throws IOException {
    int part = partitioner.getPartition(key, value, readers.length);
    return readers[part].get(key, value);
  }
289138
static ZTFilePermissions getZTFilePermissions(ZipEntry zipEntry) {
    try {
      ZTFilePermissions permissions = null;
      List<ZipExtraField> fields = ExtraFieldUtils.parse(zipEntry.getExtra());
      AsiExtraField asiExtraField = getFirstAsiExtraField(fields);
      if (asiExtraField != null) {
        int mode = asiExtraField.getMode() & 0777;
        permissions = ZTFilePermissionsUtil.fromPosixFileMode(mode);
      }
      return permissions;
    }
    catch (java.util.zip.ZipException ze) {
      throw new ZipException(ze);
    }
  }
99973
public Enumeration<JarEntry> entries() {
        final Enumeration enum_ = super.entries();
        return new Enumeration<JarEntry>() {
            public boolean hasMoreElements() {
                return enum_.hasMoreElements();
            }
            public JarFileEntry nextElement() {
                ZipEntry ze = (ZipEntry)enum_.nextElement();
                return new JarFileEntry(ze);
            }
        };
    }
195428
@SuppressWarnings("PMD.GuardLogStatement")
    public W acquire() throws InterruptedException {
        // Stop draining, because we obviously need this kind of buffers
        Optional.ofNullable(idleTimer.getAndSet(null)).ifPresent(
            timer -> timer.cancel());
        if (createdBufs.get() < maximumBufs) {
            // Haven't reached maximum, so if no buffer is queued, create one.
            W buffer = queue.poll();
            if (buffer != null) {
                buffer.lockBuffer();
                return buffer;
            }
            return createBuffer();
        }
        // Wait for buffer to become available.
        if (logger.isLoggable(Level.FINE)) {
            // If configured, log message after waiting some time.
            W buffer = queue.poll(acquireWarningLimit, TimeUnit.MILLISECONDS);
            if (buffer != null) {
                buffer.lockBuffer();
                return buffer;
            }
            logger.log(Level.FINE, new Throwable(),
                () -> Thread.currentThread().getName() + " waiting > "
                    + acquireWarningLimit + "ms for buffer, while executing:");
        }
        W buffer = queue.take();
        buffer.lockBuffer();
        return buffer;
    }
1194464
private static byte[] doUnpackEntry(ZipFile zf, String name) throws IOException {
    ZipEntry ze = zf.getEntry(name);
    if (ze == null) {
      return null; // entry not found
    }

    InputStream is = zf.getInputStream(ze);
    try {
      return IOUtils.toByteArray(is);
    }
    finally {
      IOUtils.closeQuietly(is);
    }
  }
465971
MappableJournalSegmentReader<E> createReader() {
    checkOpen();
    MappableJournalSegmentReader<E> reader = new MappableJournalSegmentReader<>(
        openChannel(file.file()), this, maxEntrySize, index, namespace);
    MappedByteBuffer buffer = writer.buffer();
    if (buffer != null) {
      reader.map(buffer);
    }
    readers.add(reader);
    return reader;
  }
1305486
public void closeEntry() throws IOException {
        ensureOpen();
        if (current != null) {
            ZipEntry e = current.entry;
            switch (e.method) {
            case DEFLATED:
                def.finish();
                while (!def.finished()) {
                    deflate();
                }
                if ((e.flag & 8) == 0) {
                    // verify size, compressed size, and crc-32 settings
                    if (e.size != def.getBytesRead()) {
                        throw new ZipException(
                            "invalid entry size (expected " + e.size +
                            " but got " + def.getBytesRead() + " bytes)");
                    }
                    if (e.csize != def.getBytesWritten()) {
                        throw new ZipException(
                            "invalid entry compressed size (expected " +
                            e.csize + " but got " + def.getBytesWritten() + " bytes)");
                    }
                    if (e.crc != crc.getValue()) {
                        throw new ZipException(
                            "invalid entry CRC-32 (expected 0x" +
                            Long.toHexString(e.crc) + " but got 0x" +
                            Long.toHexString(crc.getValue()) + ")");
                    }
                } else {
                    e.size  = def.getBytesRead();
                    e.csize = def.getBytesWritten();
                    e.crc = crc.getValue();
                    writeEXT(e);
                }
                def.reset();
                written += e.csize;
                break;
            case STORED:
                // we already know that both e.size and e.csize are the same
                if (e.size != written - locoff) {
                    throw new ZipException(
                        "invalid entry size (expected " + e.size +
                        " but got " + (written - locoff) + " bytes)");
                }
                if (e.crc != crc.getValue()) {
                    throw new ZipException(
                         "invalid entry crc-32 (expected 0x" +
                         Long.toHexString(e.crc) + " but got 0x" +
                         Long.toHexString(crc.getValue()) + ")");
                }
                break;
            default:
                throw new ZipException("invalid compression method");
            }
            crc.reset();
            current = null;
        }
    }
1043880
public ByteBuffer getByteBuffer() throws IOException
    {
        return rwChannel.map( FileChannel.MapMode.READ_ONLY, 0, file.length() );
    }
171891
public byte[] load() throws IOException, InterruptedException {
        try (InputStream is = open()) {
            return FileUtils.readAllBytesAsArray(is, uncompressedSize);
        }
    }