XZOutputStream(OutputStream, FilterOptions[]).
out
XZOutputStream(OutputStream, FilterOptions[], int).
out
XZOutputStream(out, filterOptions, XZ.CHECK_CRC64).
out
outupdateFilters(FilterOptions[]).
Currently this cannot be used to update e.g. LZMA2 options in the
middle of a XZ Block. Use endBlock() to finish the
current XZ Block before calling this function. The new filter chain
will then be used for the next XZ Block.
@param filterOptions
new filter chain to use
@throws UnsupportedOptionsException
unsupported filter chain, or trying to change
the filter chain in the middle of a Block
finish() or close()
flush() to force everything written so far to
buf
finish() or close()
flush() if flushing is wanted in addition to
If there is no unfinished Block open, this function will do nothing.
(No empty XZ Block will be created.)
This function can be useful, for example, to create
random-accessible .xz files.
Starting a new XZ Block means that the encoder state is reset.
Doing this very often will increase the size of the compressed
file a lot (more than plain flush() would do).
@throws XZIOException
XZ Stream has grown too big
@throws XZIOException
stream finished or closed
@throws IOException may be thrown by the underlying output stream
out.flush().
Calling this function very often may increase the compressed
file size a lot. The filter chain options may affect the size
increase too. For example, with LZMA2 the HC4 match finder has
smaller penalty with flushing than BT4.
Some filters don't support flushing. If the filter chain has
such a filter, flush() will call endBlock()
before flushing.
@throws XZIOException
XZ Stream has grown too big
@throws XZIOException
stream finished or closed
@throws IOException may be thrown by the underlying output stream
write with an empty buffer is OK).
Repeated calls to finish() do nothing unless
an exception was thrown by this stream earlier. In that case
the same exception is thrown again.
After finishing, the stream may be closed normally with
close(). If the stream will be closed anyway, there
usually is no need to call finish() separately.
@throws XZIOException
XZ Stream has grown too big
@throws IOException may be thrown by the underlying output stream
out is closed even if finishing
finish() is thrown and the exception from the failed
out.close() is lost.
Examples
Getting an output stream to compress with LZMA2 using the default
settings and the default integrity check type (CRC64):
Using the preset level
8for LZMA2 (the defaultis
6) and SHA-256 instead of CRC64 for integrity checking:Using the x86 BCJ filter together with LZMA2 to compress x86 executables
and printing the memory usage information before creating the
XZOutputStream: