Package org.apache.nifi.remote.io
Class CompressionOutputStream
java.lang.Object
java.io.OutputStream
org.apache.nifi.remote.io.CompressionOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
-
Field Summary
Modifier and TypeFieldDescriptionprivate final byte[]
private int
private final byte[]
private boolean
static final int
static final int
private final Deflater
static final int
private final OutputStream
static final byte[]
-
Constructor Summary
ConstructorDescriptionCompressionOutputStream
(OutputStream outStream) CompressionOutputStream
(OutputStream outStream, int bufferSize) CompressionOutputStream
(OutputStream outStream, int bufferSize, int level, int strategy) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
void
close()
Flushes remaining buffer and callsDeflater.end()
to free acquired memory to prevent OutOfMemory error.protected void
Compresses the currently buffered chunk of data and sends it to the output streamvoid
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) Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
SYNC_BYTES
public static final byte[] SYNC_BYTES -
DEFAULT_COMPRESSION_LEVEL
public static final int DEFAULT_COMPRESSION_LEVEL- See Also:
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
MIN_BUFFER_SIZE
public static final int MIN_BUFFER_SIZE- See Also:
-
out
-
deflater
-
buffer
private final byte[] buffer -
compressed
private final byte[] compressed -
bufferIndex
private int bufferIndex -
dataWritten
private boolean dataWritten
-
-
Constructor Details
-
CompressionOutputStream
-
CompressionOutputStream
-
CompressionOutputStream
-
-
Method Details
-
compressAndWrite
Compresses the currently buffered chunk of data and sends it to the output stream- Throws:
IOException
- if issues occur writing to stream
-
writeChunkHeader
- Throws:
IOException
-
writeInt
- Throws:
IOException
-
bufferFull
protected boolean bufferFull() -
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
Flushes remaining buffer and callsDeflater.end()
to free acquired memory to prevent OutOfMemory error.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
- for any issues closing underlying stream
-