Package org.brotli.dec
Class BrotliInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.brotli.dec.BrotliInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class BrotliInputStream extends java.io.InputStreamInputStreamdecorator that decompresses brotli data.Not thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]bufferInternal buffer used for efficient byte-by-byte reading.private intbufferOffsetNext unused byte offset.static intDEFAULT_INTERNAL_BUFFER_SIZEprivate static intEND_OF_STREAM_MARKERValue expected by InputStream contract when stream is over.private intremainingBufferBytesNumber of decoded but still unused bytes in internal buffer.private StatestateDecoder state.
-
Constructor Summary
Constructors Constructor Description BrotliInputStream(java.io.InputStream source)Creates aInputStreamwrapper that decompresses brotli data.BrotliInputStream(java.io.InputStream source, int byteReadBufferSize)Creates aInputStreamwrapper that decompresses brotli data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattachDictionaryChunk(byte[] data)voidclose()voidenableEagerOutput()voidenableLargeWindow()intread()intread(byte[] destBuffer, int destOffset, int destLen)
-
-
-
Field Detail
-
DEFAULT_INTERNAL_BUFFER_SIZE
public static final int DEFAULT_INTERNAL_BUFFER_SIZE
- See Also:
- Constant Field Values
-
END_OF_STREAM_MARKER
private static final int END_OF_STREAM_MARKER
Value 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:
- Constant Field Values
-
buffer
private byte[] buffer
Internal buffer used for efficient byte-by-byte reading.
-
remainingBufferBytes
private int remainingBufferBytes
Number of decoded but still unused bytes in internal buffer.
-
bufferOffset
private int bufferOffset
Next unused byte offset.
-
state
private final State state
Decoder state.
-
-
Constructor Detail
-
BrotliInputStream
public BrotliInputStream(java.io.InputStream source) throws java.io.IOExceptionCreates aInputStreamwrapper that decompresses brotli data.For byte-by-byte reading (
read()) internal buffer withDEFAULT_INTERNAL_BUFFER_SIZEsize is allocated and used.Will block the thread until first
BitReader.CAPACITYbytes of data of source are available.- Parameters:
source- underlying data source- Throws:
java.io.IOException- in case of corrupted data or source stream problems
-
BrotliInputStream
public BrotliInputStream(java.io.InputStream source, int byteReadBufferSize) throws java.io.IOExceptionCreates aInputStreamwrapper 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.CAPACITYbytes of data of source are available.- Parameters:
source- compressed data sourcebyteReadBufferSize- size of internal buffer used in case of byte-by-byte reading- Throws:
java.io.IOException- in case of corrupted data or source stream problems
-
-
Method Detail
-
attachDictionaryChunk
public void attachDictionaryChunk(byte[] data)
-
enableEagerOutput
public void enableEagerOutput()
-
enableLargeWindow
public void enableLargeWindow()
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] destBuffer, int destOffset, int destLen) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
-