| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A closer to the spec implementation of ZIP parsing for Java.
The notes and structure outlines are the basis for most of LLJ-ZIP.
The JVM zip reader implementation is based off this piece.
This is a zip format reader for seekable files, that tolerates leading and trailing garbage, and tolerates having had internal offsets adjusted for leading garbage (as with Info-Zip's zip -A).
But that's not all it does. That's just what that one comment says. Some other fun quirks of the JVM zip parser:
Maven dependency:
<dependency>
<groupId>software.coley</groupId>
<artifactId>lljzip</artifactId>
<version>${zipVersion}</version> <!-- See release page for latest version -->
</dependency>Gradle dependency:
implementation group: 'software.coley', name: 'lljzip', version: zipVersion
implementation "software.coley:lljzip:${zipVersion}"Basic usage:
// ZipIO offers a number of different utility calls for using different ZipReader implementations
ZipArchive archive = ZipIO.readJvm(path);
// Local files have the actual file data/bytes.
// These entries mirror data also declared in central directory entries.
List<LocalFileHeader> localFiles = archive.getLocalFiles();
for (LocalFileHeader localFile : localFiles) {
// Data model mirrors how a byte-buffer works.
ByteData data = localFile.getFileData();
// You can extract the data to raw byte[]
byte[] decompressed = ZipCompressions.decompress(localFile);
// Or do so with a specific decompressor implementation
byte[] decompressed = localFile.decompress(DeflateDecompressor.INSTANCE);
}
// Typically used for authoritative definitions of properties.
// Some ZIP logic will ignore properties of 'LocalFileHeader' values and use these instead.
// - Try using a hex editor to play around with this idea. Plenty of samples in the test cases to look at.
List<CentralDirectoryFileHeader> centralDirectories = archive.getCentralDirectories();
// Information about the archive and its contents.
EndOfCentralDirectory end = archive.getEnd();For more detailed example usage see the tests.
How does each ZipReader implementation map to standard Java ZIP handling?
If you're looking to see which implementation models different ways of reading ZIP files in Java, here's a table for reference:
| Java closest equivalent | LL-Java-Zip |
|---|---|
| ZipFile | JvmZipReader / ZipIO.readJvm(...) |
| ZipInputStream | ForwardScanZipReader / ZipIO.readStandard(...) |
| N/A | NaiveLocalFileZipReader / ZipIO.readNaive(...) |
There is also a ZipFile delegating reader AdaptingZipReader but it should primarily be used only for debugging purposes.
Due to some sun.misc.Unsafe hacks (For faster deflate performance), you will get compiler warnings when first opening the project in IntelliJ. You can resolve this by changing the compiler target:
| Back | FazBrowse Home | New Git URL |