Class LZMAOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class LZMAOutputStream extends FinishableOutputStream
- Since:
- 1.6
-
Constructor Summary
Constructors Constructor Description LZMAOutputStream(OutputStream out, LZMA2Options options, boolean useEndMarker)
Creates a new compressor for raw LZMA (also known as LZMA1) stream.LZMAOutputStream(OutputStream out, LZMA2Options options, boolean useEndMarker, ArrayCache arrayCache)
Creates a new compressor for raw LZMA (also known as LZMA1) stream.LZMAOutputStream(OutputStream out, LZMA2Options options, long inputSize)
Creates a new compressor for the legacy .lzma file format.LZMAOutputStream(OutputStream out, LZMA2Options options, long inputSize, ArrayCache arrayCache)
Creates a new compressor for the legacy .lzma file format. -
Method Summary
Modifier and Type Method Description void
close()
Finishes the stream and closes the underlying OutputStream.void
finish()
Finishes the stream without closing the underlying OutputStream.void
flush()
Flushing isn't supported and will throw XZIOException.int
getProps()
Returns the LZMA lc/lp/pb properties encoded into a single byte.long
getUncompressedSize()
Gets the amount of uncompressed data written to the stream.void
write(byte[] buf, int off, int len)
void
write(int b)
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
LZMAOutputStream
Creates a new compressor for the legacy .lzma file format.If the uncompressed size of the input data is known, it will be stored in the .lzma header and no end of stream marker will be used. Otherwise the header will indicate unknown uncompressed size and the end of stream marker will be used.
Note that a preset dictionary cannot be used in .lzma files but it can be used for raw LZMA streams.
- Parameters:
out
- output stream to which the compressed data will be writtenoptions
- LZMA compression options; the same class is used here as is for LZMA2inputSize
- uncompressed size of the data to be compressed; use-1
when unknown- Throws:
IOException
- may be thrown fromout
-
LZMAOutputStream
public LZMAOutputStream(OutputStream out, LZMA2Options options, long inputSize, ArrayCache arrayCache) throws IOExceptionCreates a new compressor for the legacy .lzma file format.This is identical to
LZMAOutputStream(OutputStream, LZMA2Options, long)
except that this also takes thearrayCache
argument.- Parameters:
out
- output stream to which the compressed data will be writtenoptions
- LZMA compression options; the same class is used here as is for LZMA2inputSize
- uncompressed size of the data to be compressed; use-1
when unknownarrayCache
- cache to be used for allocating large arrays- Throws:
IOException
- may be thrown fromout
- Since:
- 1.7
-
LZMAOutputStream
public LZMAOutputStream(OutputStream out, LZMA2Options options, boolean useEndMarker) throws IOExceptionCreates a new compressor for raw LZMA (also known as LZMA1) stream.Raw LZMA streams can be encoded with or without end of stream marker. When decompressing the stream, one must know if the end marker was used and tell it to the decompressor. If the end marker wasn't used, the decompressor will also need to know the uncompressed size.
- Parameters:
out
- output stream to which the compressed data will be writtenoptions
- LZMA compression options; the same class is used here as is for LZMA2useEndMarker
- if end of stream marker should be written- Throws:
IOException
- may be thrown fromout
-
LZMAOutputStream
public LZMAOutputStream(OutputStream out, LZMA2Options options, boolean useEndMarker, ArrayCache arrayCache) throws IOExceptionCreates a new compressor for raw LZMA (also known as LZMA1) stream.This is identical to
LZMAOutputStream(OutputStream, LZMA2Options, boolean)
except that this also takes thearrayCache
argument.- Parameters:
out
- output stream to which the compressed data will be writtenoptions
- LZMA compression options; the same class is used here as is for LZMA2useEndMarker
- if end of stream marker should be writtenarrayCache
- cache to be used for allocating large arrays- Throws:
IOException
- may be thrown fromout
- Since:
- 1.7
-
-
Method Details
-
getProps
public int getProps()Returns the LZMA lc/lp/pb properties encoded into a single byte. This might be useful when handling file formats other than .lzma that use the same encoding for the LZMA properties as .lzma does. -
getUncompressedSize
public long getUncompressedSize()Gets the amount of uncompressed data written to the stream. This is useful when creating raw LZMA streams without the end of stream marker. -
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
flush
Flushing isn't supported and will throw XZIOException.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
finish
Finishes the stream without closing the underlying OutputStream.- Overrides:
finish
in classFinishableOutputStream
- Throws:
IOException
-
close
Finishes the stream and closes the underlying OutputStream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-