public final class ZLib
extends java.lang.Object
zlib is designed to be a free, general-purpose, legally unencumbered - that is, not covered by any patents -- lossless data-compression library for use on virtually any computer hardware and operating system. The zlib data format is itself portable across platforms.
Modifier and Type | Field and Description |
---|---|
static int |
BEST_COMPRESSION
Compression level for best compression, which is 9 in a scale from 0 (no compression) to 9 (best compression).
|
static int |
BEST_SPEED
Compression level for fastest compression, which is 1 in a scale from 0 (no compression) to 9 (best compression).
|
static int |
DEFAULT_COMPRESSION
Default compression level.
|
static int |
DEFAULT_STRATEGY
Default compression strategy.
|
static int |
DEFLATED
Compression method for the deflate algorithm (the only one currently supported).
|
static int |
FILTERED
Compression strategy best used for data consisting mostly of small values with a somewhat random distribution.
|
static int |
HUFFMAN_ONLY
Compression strategy for Huffman coding only.
|
static int |
NO_COMPRESSION
Compression level for no compression, which is 0 in a scale from 0 (no compression) to 9 (best compression)
|
Modifier and Type | Method and Description |
---|---|
static int |
deflate(int compressionLevel,
Stream in,
Stream out)
Deprecated.
use #deflate(Stream, Stream, int) instead
|
static int |
deflate(Stream in,
Stream out)
Deflates the given stream 'in' with the specified compression level, writing the result to the given stream 'out'.
|
static int |
deflate(Stream in,
Stream out,
int compressionLevel)
Deflates the given stream 'in' with the specified compression level, writing the result to the given stream 'out'.
|
static int |
deflate(Stream in,
Stream out,
int compressionLevel,
int strategy,
boolean noWrap)
Deflates the given stream 'in' using the specified strategy and compression level, writing the result to the given
stream 'out'.
|
static int |
inflate(Stream in,
Stream out)
Attempts to fully read the given stream 'in', inflating and writing to the given stream 'out'.
|
static int |
inflate(Stream in,
Stream out,
int sizeIn)
Attempts to read the number of bytes specified by 'sizeIn' from the the given stream 'in', inflating and writing
to the given stream 'out'.
|
static int |
inflate(Stream in,
Stream out,
int sizeIn,
boolean noWrap)
Attempts to read the number of bytes specified by 'sizeIn' from the the given stream 'in', inflating and writing
to the given stream 'out'.
|
public static final int NO_COMPRESSION
public static final int BEST_SPEED
public static final int BEST_COMPRESSION
public static final int DEFAULT_COMPRESSION
public static final int DEFAULT_STRATEGY
public static final int DEFLATED
public static final int FILTERED
public static final int HUFFMAN_ONLY
public static int deflate(Stream in, Stream out) throws IOException
in
- Stream to be deflatedout
- Deflated stream.IOException
DEFAULT_COMPRESSION
public static int deflate(Stream in, Stream out, int compressionLevel) throws IOException
in
- Stream to be deflatedout
- Deflated stream.compressionLevel
- Desired compression level, which must be between 0 and 9, or -1 for the default compression levelIOException
NO_COMPRESSION
,
BEST_SPEED
,
BEST_COMPRESSION
@Deprecated public static int deflate(int compressionLevel, Stream in, Stream out) throws IOException
compressionLevel
- Desired compression level, which must be between 0 and 9, or -1 for the default compression levelin
- Stream to be deflatedout
- Deflated stream.IOException
NO_COMPRESSION
,
BEST_SPEED
,
BEST_COMPRESSION
public static int deflate(Stream in, Stream out, int compressionLevel, int strategy, boolean noWrap) throws IOException
in
- Stream to be deflatedout
- Deflated stream.compressionLevel
- compression level, which must be between 0 and 9, or -1 for the default compression levelstrategy
- the compression strategynoWrap
- if true then use GZIP compatible compressionIOException
NO_COMPRESSION
,
BEST_SPEED
,
BEST_COMPRESSION
public static int inflate(Stream in, Stream out) throws IOException, ZipException
in
- Deflated input streamout
- Inflated output streamIOException
ZipException
public static int inflate(Stream in, Stream out, int sizeIn) throws IOException, ZipException
in
- Deflated input streamout
- Inflated output streamsizeIn
- How many bytes to read, or -1 to read until in
's endZipException
IOException
public static int inflate(Stream in, Stream out, int sizeIn, boolean noWrap) throws IOException, ZipException
in
- Deflated input streamout
- Inflated output streamsizeIn
- How many bytes to read, or -1 to read until in
's endnoWrap
- if true then support GZIP compatible compressionZipException
IOException