Factory to create Compressor[In|Out]putStreams from names. To add other implementations you should extend CompressorStreamFactory and override the appropriate methods (and call their implementation from super of course).
Example (Compressing a file):final OutputStream out = Files.newOutputStream(output.toPath()); CompressorOutputStream cos = new CompressorStreamFactory().createCompressorOutputStream(CompressorStreamFactory.BZIP2, out); IOUtils.copy(Files.newInputStream(input.toPath()), cos); cos.close();Example (Decompressing a file):
final InputStream is = Files.newInputStream(input.toPath()); CompressorInputStream in = new CompressorStreamFactory().createCompressorInputStream(CompressorStreamFactory.BZIP2, is); IOUtils.copy(in, Files.newOutputStream(output.toPath())); in.close();
| Modifier and Type | Field and Description |
|---|---|
| private static final Set | |
| public static final String | BROTLI
Constant (value br) used to identify the BROTLI compression algorithm. |
| public static final String | BZIP2
Constant (value bzip2) used to identify the BZIP2 compression algorithm. |
| private SortedMap | |
| private SortedMap | |
| private volatile boolean | decompressConcatenated
If true, decompress until the end of the input. |
| private final Boolean | decompressUntilEOF
If true, decompress until the end of the input. |
| public static final String | DEFLATE
Constant (value deflate) used to identify the Deflate compress method. |
| public static final String | DEFLATE64
Constant (value deflate64) used to identify the Deflate64 compress method. |
| public static final String | GZIP
Constant (value gz) used to identify the GZIP compression algorithm. |
| public static final String | LZ4_BLOCK
Constant (value lz4-block) used to identify the block LZ4 compression method. |
| public static final String | LZ4_FRAMED
Constant (value lz4-framed) used to identify the frame LZ4 compression method. |
| public static final String | LZMA
Constant (value lzma) used to identify the LZMA compression method. |
| private final int | |
| public static final String | PACK200
Constant (value pack200) used to identify the PACK200 compression algorithm. |
| private static final CompressorStreamFactory | |
| public static final String | SNAPPY_FRAMED
Constant (value snappy-framed) used to identify the "framed" Snappy compression method. |
| public static final String | SNAPPY_RAW
Constant (value snappy-raw) used to identify the "raw" Snappy compression method. |
| public static final String | XZ
Constant (value xz) used to identify the XZ compression method. |
| private static final String | |
| private static final String | |
| private static final String | |
| public static final String | Z
Constant (value z) used to identify the traditional Unix compress method. |
| public static final String | ZSTANDARD
Constant (value zstd) used to identify the Zstandard compression algorithm. |
| Access | Constructor and Description |
|---|---|
| public | CompressorStreamFactory()
Constructs an instance with the decompress Concatenated option set to false. |
| public | CompressorStreamFactory(final boolean
if true, decompress until the end of the input; if false, stop after the first stream and leave the input position to point to
the next byte after the stream. This setting applies to the gzip, bzip2 and XZ formats only. decompressUntilEOF)Constructs an instance with the provided decompress Concatenated option. |
| public | CompressorStreamFactory(final boolean
if true, decompress until the end of the input; if false, stop after the first stream and leave the input position to point to
the next byte after the stream. This setting applies to the gzip, bzip2 and XZ formats only. decompressUntilEOF, final int Some streams require allocation of potentially significant byte arrays/tables, and they can offer checks to prevent OOMs on
corrupt files. Set the maximum allowed memory allocation in KBs. memoryLimitInKb)Constructs an instance with the provided decompress Concatenated option. |
| Modifier and Type | Method and Description |
|---|---|
| private static Iterable | |
| public CompressorInputStream | Returns: the compressor input streamthe input stream in)Creates a compressor input stream from an input stream, auto-detecting the compressor type from the first few bytes of the stream. |
| public CompressorInputStream | Returns: the compressor input streamthe input stream in, final Set<String> compressor names to limit autodetection compressorNames)Creates a compressor input stream from an input stream, auto-detecting the compressor type from the first few bytes of the stream while limiting the detected type to the provided set of compressor names. |
| public CompressorInputStream | Returns: compressor input streamof the compressor, i.e. gz, bzip2, xz, lzma, pack200, snappy-raw,
snappy-framed, z, lz4-block, lz4-framed, zstd, deflate64 or
deflate name, final InputStream the input stream in)Creates a compressor input stream from a compressor name and an input stream. |
| public CompressorInputStream | createCompressorInputStream(final String
of the compressor, i.e. gz,
bzip2,
xz,
lzma,
pack200,
snappy-raw,
snappy-framed,
z or
deflate name, final InputStream the input stream in, final boolean if true, decompress until the end of the input; if false, stop after the first stream and leave the input position to point to
the next byte after the stream. This setting applies to the gzip, bzip2 and XZ formats only. actualDecompressConcatenated)Implements org. |
| public CompressorOutputStream | Returns: the compressor output streamthe compressor name, i.e. gz, bzip2, xz, pack200, snappy-framed, lz4-block,
lz4-framed, zstd or deflate name, final OutputStream the output stream out)Implements org. |
| public static String | Returns: type of compressor stream detectedinput stream inputStream)Detects the type of compressor stream. |
| pack-priv static String | Returns: type of compressor stream detectedinput stream inputStream, final Set<String> compressor names to limit autodetection compressorNames)Detects the type of compressor stream while limiting the type to the provided set of compressor names. |
| public static SortedMap | Returns: An immutable, map from names to provider objectsConstructs a new sorted map from input stream provider names to provider objects. |
| public static SortedMap | Returns: An immutable, map from names to provider objectsConstructs a new sorted map from output stream provider names to provider objects. |
| public static String | |
| public static String | |
| public SortedMap | |
| public SortedMap | |
| pack-priv boolean | |
| public Boolean | |
| public static String | |
| public static String | |
| public static String | |
| public Set | getInputStreamCompressorNames()
Implements org. |
| public static String | |
| public static String | |
| public static String | |
| public Set | getOutputStreamCompressorNames()
Implements org. |
| public static String | |
| public static CompressorStreamFactory | |
| public static String | |
| public static String | |
| public static String | |
| public static String | |
| public static String | |
| pack-priv static void | putAll(final Set<String> names, final CompressorStreamProvider provider, final TreeMap<String, CompressorStreamProvider> map)
|
| public void | setDecompressConcatenated(final boolean
if true, decompress until the end of the input; if false, stop after the first stream and leave the input position to point
to the next byte after the stream decompressConcatenated)
Deprecated
1.10 use the
Sets whether to decompress the full input or only the first stream in formats supporting multiple concatenated input streams.
CompressorStreamFactory(boolean) constructor instead
|
| private static String | |
| private static String |
| ALL_NAMES | back to summary |
|---|---|
| private static final Set<String> ALL_NAMES | |
| BROTLI | back to summary |
|---|---|
| public static final String BROTLI Constant (value br) used to identify the BROTLI compression algorithm.
| |
| BZIP2 | back to summary |
|---|---|
| public static final String BZIP2 Constant (value bzip2) used to identify the BZIP2 compression algorithm.
| |
| compressorInputStreamProviders | back to summary |
|---|---|
| private SortedMap<String, CompressorStreamProvider> compressorInputStreamProviders | |
| compressorOutputStreamProviders | back to summary |
|---|---|
| private SortedMap<String, CompressorStreamProvider> compressorOutputStreamProviders | |
| decompressConcatenated | back to summary |
|---|---|
| private volatile boolean decompressConcatenated If true, decompress until the end of the input. If false, stop after the first stream and leave the input position to point to the next byte after the stream | |
| decompressUntilEOF | back to summary |
|---|---|
| private final Boolean decompressUntilEOF If true, decompress until the end of the input. If false, stop after the first stream and leave the input position to point to the next byte after the stream | |
| DEFLATE | back to summary |
|---|---|
| public static final String DEFLATE Constant (value deflate) used to identify the Deflate compress method.
| |
| DEFLATE64 | back to summary |
|---|---|
| public static final String DEFLATE64 Constant (value deflate64) used to identify the Deflate64 compress method.
| |
| GZIP | back to summary |
|---|---|
| public static final String GZIP Constant (value gz) used to identify the GZIP compression algorithm.
| |
| LZ4_BLOCK | back to summary |
|---|---|
| public static final String LZ4_BLOCK Constant (value lz4-block) used to identify the block LZ4 compression method.
| |
| LZ4_FRAMED | back to summary |
|---|---|
| public static final String LZ4_FRAMED Constant (value lz4-framed) used to identify the frame LZ4 compression method.
| |
| LZMA | back to summary |
|---|---|
| public static final String LZMA Constant (value lzma) used to identify the LZMA compression method.
| |
| memoryLimitInKb | back to summary |
|---|---|
| private final int memoryLimitInKb | |
| PACK200 | back to summary |
|---|---|
| public static final String PACK200 Constant (value pack200) used to identify the PACK200 compression algorithm.
| |
| SINGLETON | back to summary |
|---|---|
| private static final CompressorStreamFactory SINGLETON | |
| SNAPPY_FRAMED | back to summary |
|---|---|
| public static final String SNAPPY_FRAMED Constant (value snappy-framed) used to identify the "framed" Snappy compression method.
| |
| SNAPPY_RAW | back to summary |
|---|---|
| public static final String SNAPPY_RAW Constant (value snappy-raw) used to identify the "raw" Snappy compression method. Not supported as an output stream type.
| |
| XZ | back to summary |
|---|---|
| public static final String XZ Constant (value xz) used to identify the XZ compression method.
| |
| YOU_NEED_BROTLI_DEC | back to summary |
|---|---|
| private static final String YOU_NEED_BROTLI_DEC | |
| YOU_NEED_XZ_JAVA | back to summary |
|---|---|
| private static final String YOU_NEED_XZ_JAVA | |
| YOU_NEED_ZSTD_JNI | back to summary |
|---|---|
| private static final String YOU_NEED_ZSTD_JNI | |
| Z | back to summary |
|---|---|
| public static final String Z Constant (value z) used to identify the traditional Unix compress method. Not supported as an output stream type.
| |
| ZSTANDARD | back to summary |
|---|---|
| public static final String ZSTANDARD Constant (value zstd) used to identify the Zstandard compression algorithm. Not supported as an output stream type.
| |
| CompressorStreamFactory | back to summary |
|---|---|
| public CompressorStreamFactory() Constructs an instance with the decompress Concatenated option set to false. | |
| CompressorStreamFactory | back to summary |
|---|---|
| public CompressorStreamFactory(final boolean decompressUntilEOF) Constructs an instance with the provided decompress Concatenated option.
| |
| CompressorStreamFactory | back to summary |
|---|---|
| public CompressorStreamFactory(final boolean decompressUntilEOF, final int memoryLimitInKb) Constructs an instance with the provided decompress Concatenated option.
| |
| archiveStreamProviderIterable | back to summary |
|---|---|
| private static Iterable | |
| createCompressorInputStream | back to summary |
|---|---|
| public CompressorInputStream createCompressorInputStream(final InputStream in) throws CompressorException Creates a compressor input stream from an input stream, auto-detecting the compressor type from the first few bytes of the stream. The InputStream must support marks, like BufferedInputStream.
| |
| createCompressorInputStream | back to summary |
|---|---|
| public CompressorInputStream createCompressorInputStream(final InputStream in, final Set<String> compressorNames) throws CompressorException Creates a compressor input stream from an input stream, auto-detecting the compressor type from the first few bytes of the stream while limiting the detected type to the provided set of compressor names. The InputStream must support marks, like BufferedInputStream.
| |
| createCompressorInputStream | back to summary |
|---|---|
| public CompressorInputStream createCompressorInputStream(final String name, final InputStream in) throws CompressorException Creates a compressor input stream from a compressor name and an input stream.
| |
| createCompressorInputStream | back to summary |
|---|---|
| public CompressorInputStream createCompressorInputStream(final String name, final InputStream in, final boolean actualDecompressConcatenated) throws CompressorException Implements org. Doc from org. Creates a compressor input stream from a compressor name and an input stream.
| |
| createCompressorOutputStream | back to summary |
|---|---|
| public CompressorOutputStream createCompressorOutputStream(final String name, final OutputStream out) throws CompressorException Implements org. Creates a compressor output stream from a compressor name and an output stream.
| |
| detect | back to summary |
|---|---|
| public static String detect(final InputStream inputStream) throws CompressorException Detects the type of compressor stream.
| |
| detect | back to summary |
|---|---|
| pack-priv static String detect(final InputStream inputStream, final Set<String> compressorNames) throws CompressorException Detects the type of compressor stream while limiting the type to the provided set of compressor names.
| |
| findAvailableCompressorInputStreamProviders | back to summary |
|---|---|
| public static SortedMap Constructs a new sorted map from input stream provider names to provider objects. The map returned by this method will have one entry for each provider for which support is available in the current Java virtual machine. If two or more supported provider have the same name then the resulting map will contain just one of them; which one it will contain is not specified. The invocation of this method, and the subsequent use of the resulting map, may cause time-consuming disk or network I/O operations to occur. This method is provided for applications that need to enumerate all of the available providers, for example to allow user provider selection. This method may return different results at different times if new providers are dynamically made available to the current Java virtual machine.
| |
| findAvailableCompressorOutputStreamProviders | back to summary |
|---|---|
| public static SortedMap Constructs a new sorted map from output stream provider names to provider objects. The map returned by this method will have one entry for each provider for which support is available in the current Java virtual machine. If two or more supported provider have the same name then the resulting map will contain just one of them; which one it will contain is not specified. The invocation of this method, and the subsequent use of the resulting map, may cause time-consuming disk or network I/O operations to occur. This method is provided for applications that need to enumerate all of the available providers, for example to allow user provider selection. This method may return different results at different times if new providers are dynamically made available to the current Java virtual machine.
| |
| getBrotli | back to summary |
|---|---|
| public static String getBrotli() | |
| getBzip2 | back to summary |
|---|---|
| public static String getBzip2() | |
| getCompressorInputStreamProviders | back to summary |
|---|---|
| public SortedMap | |
| getCompressorOutputStreamProviders | back to summary |
|---|---|
| public SortedMap | |
| getDecompressConcatenated | back to summary |
|---|---|
| pack-priv boolean getDecompressConcatenated() For tests. | |
| getDecompressUntilEOF | back to summary |
|---|---|
| public Boolean getDecompressUntilEOF() | |
| getDeflate | back to summary |
|---|---|
| public static String getDeflate() | |
| getDeflate64 | back to summary |
|---|---|
| public static String getDeflate64() | |
| getGzip | back to summary |
|---|---|
| public static String getGzip() | |
| getInputStreamCompressorNames | back to summary |
|---|---|
| public Set Implements org. Doc from org. Gets all the input stream compressor names for this provider | |
| getLZ4Block | back to summary |
|---|---|
| public static String getLZ4Block() | |
| getLZ4Framed | back to summary |
|---|---|
| public static String getLZ4Framed() | |
| getLzma | back to summary |
|---|---|
| public static String getLzma() | |
| getOutputStreamCompressorNames | back to summary |
|---|---|
| public Set Implements org. Doc from org. Gets all the output stream compressor names for this provider | |
| getPack200 | back to summary |
|---|---|
| public static String getPack200() | |
| getSingleton | back to summary |
|---|---|
| public static CompressorStreamFactory getSingleton() | |
| getSnappyFramed | back to summary |
|---|---|
| public static String getSnappyFramed() | |
| getSnappyRaw | back to summary |
|---|---|
| public static String getSnappyRaw() | |
| getXz | back to summary |
|---|---|
| public static String getXz() | |
| getZ | back to summary |
|---|---|
| public static String getZ() | |
| getZstandard | back to summary |
|---|---|
| public static String getZstandard() | |
| putAll | back to summary |
|---|---|
| pack-priv static void putAll(final Set<String> names, final CompressorStreamProvider provider, final TreeMap<String, CompressorStreamProvider> map) | |
| setDecompressConcatenated | back to summary |
|---|---|
| public void setDecompressConcatenated(final boolean decompressConcatenated)
Deprecated 1.10 use the Sets whether to decompress the full input or only the first stream in formats supporting multiple concatenated input streams. This setting applies to the gzip, bzip2 and XZ formats only.
| |
| toKey | back to summary |
|---|---|
| private static String toKey(final String name) | |
| youNeed | back to summary |
|---|---|
| private static String youNeed(final String name, final String url) | |