public class CompressionOutputStream extends OutputStream
| Modifier and Type | Field and Description |
|---|---|
private byte[] |
buffer |
private int |
bufferIndex |
private byte[] |
compressed |
private boolean |
dataWritten |
static int |
DEFAULT_BUFFER_SIZE |
static int |
DEFAULT_COMPRESSION_LEVEL |
private Deflater |
deflater |
static int |
MIN_BUFFER_SIZE |
private OutputStream |
out |
static byte[] |
SYNC_BYTES |
| Constructor and Description |
|---|
CompressionOutputStream(OutputStream outStream) |
CompressionOutputStream(OutputStream outStream,
int bufferSize) |
CompressionOutputStream(OutputStream outStream,
int bufferSize,
int level,
int strategy) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
bufferFull() |
void |
close()
Flushes remaining buffer and calls
Deflater.end() to free acquired memory to prevent OutOfMemory error. |
protected void |
compressAndWrite()
Compresses the currently buffered chunk of data and sends it to the output stream
|
void |
flush() |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
private void |
writeChunkHeader(int compressedBytes) |
private void |
writeInt(OutputStream out,
int val) |
public static final byte[] SYNC_BYTES
public static final int DEFAULT_COMPRESSION_LEVEL
public static final int DEFAULT_BUFFER_SIZE
public static final int MIN_BUFFER_SIZE
private final OutputStream out
private final Deflater deflater
private final byte[] buffer
private final byte[] compressed
private int bufferIndex
private boolean dataWritten
public CompressionOutputStream(OutputStream outStream)
public CompressionOutputStream(OutputStream outStream, int bufferSize)
public CompressionOutputStream(OutputStream outStream, int bufferSize, int level, int strategy)
protected void compressAndWrite()
throws IOException
IOException - if issues occur writing to streamprivate void writeChunkHeader(int compressedBytes)
throws IOException
IOExceptionprivate void writeInt(OutputStream out, int val) throws IOException
IOExceptionprotected boolean bufferFull()
public void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic void close()
throws IOException
Deflater.end() to free acquired memory to prevent OutOfMemory error.close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOException - for any issues closing underlying streamCopyright © 2023 Apache NiFi Project. All rights reserved.