Pack200
Pack200 compresses JAR files into .pack files. Select it with Compression.pack200().
Options: strategy (IN_MEMORY or TEMP_FILE buffering) and properties (the packer and unpacker properties). The packer loses the content of deflated streamed JAR entries, so write entries STORED with size and CRC.
Decompressor never detects Pack200, and the tar extractor does not read it. An explicit Pack200 decode runs eagerly in build() and extraction limits do not bound it: select it only for trusted input.
Dependency
Writing Pack200 needs org.ow2.asm:asm on the class path. Without it, opening a Pack200 write throws MissingArchiveDependencyException. The test suite runs against ASM 9.11. See Additional Formats.
Example Usage
Path sourceJar = Path.of("example.jar");
Path targetPack = Path.of("example.pack");
try (var compressor =
Compressor.builder(targetPack, Compression.pack200()).build()) {
compressor.write(sourceJar);
}
Path sourcePack = Path.of("example.pack");
Path targetJar = Path.of("example.jar");
try (var decompressor =
Decompressor.builder(sourcePack, Compression.pack200()).build()) {
decompressor.write(targetJar);
}
|
Removal of Pack200 Tools and API
The Pack200 tools and API were deprecated in JDK 11 and removed in JDK 14. |