Package org.brotli.dec
Class BrotliInputStream
java.lang.Object
java.io.InputStream
org.brotli.dec.BrotliInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
InputStream
decorator that decompresses brotli data.
Not thread-safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]
Internal buffer used for efficient byte-by-byte reading.private int
Next unused byte offset.static final int
private static final int
Value expected by InputStream contract when stream is over.private int
Number of decoded but still unused bytes in internal buffer.private final State
Decoder state. -
Constructor Summary
ConstructorsConstructorDescriptionBrotliInputStream
(InputStream source) Creates aInputStream
wrapper that decompresses brotli data.BrotliInputStream
(InputStream source, int byteReadBufferSize) Creates aInputStream
wrapper that decompresses brotli data. -
Method Summary
Modifier and TypeMethodDescriptionvoid
attachDictionaryChunk
(byte[] data) void
close()
void
void
int
read()
int
read
(byte[] destBuffer, int destOffset, int destLen) Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset, skip
-
Field Details
-
DEFAULT_INTERNAL_BUFFER_SIZE
public static final int DEFAULT_INTERNAL_BUFFER_SIZE- See Also:
-
END_OF_STREAM_MARKER
private static final int END_OF_STREAM_MARKERValue expected by InputStream contract when stream is over. In Java it is -1. In C# it is 0 (should be patched during transpilation).- See Also:
-
buffer
private byte[] bufferInternal buffer used for efficient byte-by-byte reading. -
remainingBufferBytes
private int remainingBufferBytesNumber of decoded but still unused bytes in internal buffer. -
bufferOffset
private int bufferOffsetNext unused byte offset. -
state
Decoder state.
-
-
Constructor Details
-
BrotliInputStream
Creates aInputStream
wrapper that decompresses brotli data.For byte-by-byte reading (
read()
) internal buffer withDEFAULT_INTERNAL_BUFFER_SIZE
size is allocated and used.Will block the thread until first
BitReader.CAPACITY
bytes of data of source are available.- Parameters:
source
- underlying data source- Throws:
IOException
- in case of corrupted data or source stream problems
-
BrotliInputStream
Creates aInputStream
wrapper that decompresses brotli data.For byte-by-byte reading (
read()
) internal buffer of specified size is allocated and used.Will block the thread until first
BitReader.CAPACITY
bytes of data of source are available.- Parameters:
source
- compressed data sourcebyteReadBufferSize
- size of internal buffer used in case of byte-by-byte reading- Throws:
IOException
- in case of corrupted data or source stream problems
-
-
Method Details
-
attachDictionaryChunk
public void attachDictionaryChunk(byte[] data) -
enableEagerOutput
public void enableEagerOutput() -
enableLargeWindow
public void enableLargeWindow() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-