public final class LZ4BlockOutputStream extends FilterOutputStream
This class compresses data into fixed-size blocks of compressed data.
LZ4BlockInputStream
out
Constructor and Description |
---|
LZ4BlockOutputStream(OutputStream out)
Creates a new instance which compresses into blocks of 64 KB.
|
LZ4BlockOutputStream(OutputStream out,
int blockSize)
Creates a new instance which compresses with the standard LZ4 compression
algorithm.
|
LZ4BlockOutputStream(OutputStream out,
int blockSize,
LZ4Compressor compressor)
Creates a new instance which checks stream integrity using
StreamingXXHash32 and doesn't sync flush. |
LZ4BlockOutputStream(OutputStream out,
int blockSize,
LZ4Compressor compressor,
Checksum checksum,
boolean syncFlush)
Creates a new
OutputStream with configurable block size. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
finish()
Same as
close() except that it doesn't close the underlying stream. |
void |
flush()
Flushes this compressed
OutputStream . |
String |
toString() |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public LZ4BlockOutputStream(OutputStream out, int blockSize, LZ4Compressor compressor, Checksum checksum, boolean syncFlush)
OutputStream
with configurable block size. Large
blocks require more memory at compression and decompression time but
should improve the compression ratio.out
- the OutputStream
to feedblockSize
- the maximum number of bytes to try to compress at once,
must be >= 64 and <= 32 Mcompressor
- the LZ4Compressor
instance to use to compress
datachecksum
- the Checksum
instance to use to check data for
integrity.syncFlush
- true if pending data should also be flushed on flush()
public LZ4BlockOutputStream(OutputStream out, int blockSize, LZ4Compressor compressor)
StreamingXXHash32
and doesn't sync flush.out
- the OutputStream
to feedblockSize
- the maximum number of bytes to try to compress at once,
must be >= 64 and <= 32 Mcompressor
- the LZ4Compressor
instance to use to compress
dataLZ4BlockOutputStream(OutputStream, int, LZ4Compressor, Checksum, boolean)
,
StreamingXXHash32.asChecksum()
public LZ4BlockOutputStream(OutputStream out, int blockSize)
out
- the OutputStream
to feedblockSize
- the maximum number of bytes to try to compress at once,
must be >= 64 and <= 32 MLZ4BlockOutputStream(OutputStream, int, LZ4Compressor)
,
LZ4Factory.fastCompressor()
public LZ4BlockOutputStream(OutputStream out)
out
- the OutputStream
to feedLZ4BlockOutputStream(OutputStream, int)
public void write(int b) throws IOException
write
in class FilterOutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class FilterOutputStream
IOException
public void write(byte[] b) throws IOException
write
in class FilterOutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterOutputStream
IOException
public void flush() throws IOException
OutputStream
.
If the stream has been created with syncFlush=true
, pending
data will be compressed and appended to the underlying OutputStream
before calling OutputStream.flush()
on the underlying stream.
Otherwise, this method just flushes the underlying stream, so pending
data might not be available for reading until finish()
or
close()
is called.flush
in interface Flushable
flush
in class FilterOutputStream
IOException
public void finish() throws IOException
close()
except that it doesn't close the underlying stream.
This can be useful if you want to keep on using the underlying stream.IOException
- if an I/O error occurs.