ZipFile

open class ZipFile : Closeable

Replacement for java.util.ZipFile.

This class adds support for file name encodings other than UTF-8 (which is required to work on ZIP files created by native ZIP tools and is able to skip a preamble like the one found in self extracting archives. Furthermore it returns instances of org.readium.r2.shared.util.archive.remote.zip.ZipArchiveEntry instead of java.util.zip.ZipEntry.

It doesn't extend java.util.zip.ZipFile as it would have to reimplement all methods anyway. Like java.util.ZipFile, it uses SeekableByteChannel under the covers and supports compressed and uncompressed entries. As of Apache Commons Compress 1.3 it also transparently supports Zip64 extensions and thus individual entries and archives larger than 4 GB or with more than 65536 entries.

The method signatures mimic the ones of java.util.zip.ZipFile, with a couple of exceptions:

  • There is no getName method.
  • entries has been renamed to getEntries.
  • getEntries and getEntry return org.readium.r2.shared.util.archive.remote.zip.ZipArchiveEntry instances.
  • close is allowed to throw IOException.

Constructors

Link copied to clipboard
constructor(channel: SeekableByteChannel)
Opens the given channel for reading, assuming "UTF8" for file names.
constructor(channel: SeekableByteChannel, encoding: String)
Opens the given channel for reading, assuming the specified encoding for file names.
constructor(channel: SeekableByteChannel, ignoreLocalFileHeader: Boolean)
constructor(channel: SeekableByteChannel, archiveName: String, encoding: String, useUnicodeExtraFields: Boolean)
Opens the given channel for reading, assuming the specified encoding for file names.
constructor(channel: SeekableByteChannel, archiveName: String, encoding: String, useUnicodeExtraFields: Boolean, ignoreLocalFileHeader: Boolean)
Opens the given channel for reading, assuming the specified encoding for file names.

Properties

Link copied to clipboard
The encoding to use for file names and the file comment.
Link copied to clipboard

Functions

Link copied to clipboard
Whether this class is able to read the given entry.
Link copied to clipboard
open fun close()
Closes the archive.
Link copied to clipboard
open fun closeQuietly(zipfile: ZipFile)
close a zipfile quietly; throw no io fault, do nothing on a null parameter
Link copied to clipboard
Transfer selected entries from this zipfile to a given #ZipArchiveOutputStream.
Link copied to clipboard
Gets an InputStream for reading the content before the first local file header.
Link copied to clipboard
Gets all entries.
Gets all named entries in the same order they appear within the archive's central directory.
Link copied to clipboard
Gets all entries in physical order.
Gets all named entries in the same order their contents appear within the archive.
Link copied to clipboard
Gets a named entry or null if no entry by that name exists.
Link copied to clipboard
Gets an InputStream for reading the contents of the given entry.
Link copied to clipboard
Gets the raw stream of the archive entry (compressed form).
Gets the raw stream of the stored archive entry starting from fromIndex.
Link copied to clipboard
Gets the entry's content as a String if isUnixSymlink() returns true for it, otherwise returns null.