| Modifier and Type | Field and Description |
|---|---|
| private byte[] | buffer
The buffer. |
| private int | endIndex
How far is the buffer filled with valid data. |
| private int | index
Current read position in the buffer. |
| private static final int | MINIMUM_READ
If a direct read to byte array is called that would require a smaller read from the wrapped stream that MINIMUM_READ then first fill the buffer and serve the bytes from there. |
| private static final int | STRING_SCAN_SPAN
In how large spans is the C string zero-byte scanned. |
| private boolean | timeoutRequested
socket timeout has been requested |
| private final InputStream | wrapped
The wrapped input stream. |
| Access | Constructor and Description |
|---|---|
| public | VisibleBufferedInputStream(InputStream
The stream to buffer. in, int The initial size of the buffer. bufferSize)Creates a new buffer around the given stream. |
| Modifier and Type | Method and Description |
|---|---|
| public int | available()
Overrides java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. |
| public void | close()
Overrides java. Implements java. Closes this input stream and releases any system resources associated with the stream. |
| private void | |
| private void | |
| public boolean | Returns: true if required bytes are available and false if EOFThe amount of bytes to ensure exists in buffer n)Ensures that the buffer contains at least n bytes. |
| public boolean | Returns: true if required bytes are available and false if EOF or the parameter block was false and socket timeout occurred.The amount of bytes to ensure exists in buffer n, boolean whether or not to block the IO block)Ensures that the buffer contains at least n bytes. |
| public byte[] | |
| public int | Returns: the current read position in the buffer.Returns the current read position in the buffer. |
| public InputStream | |
| private void | moveBufferTo(byte[]
The destination buffer. dest)Moves bytes from the buffer to the beginning of the destination buffer. |
| public int | Returns: byte from the buffer without advancing the index pointerReads a byte from the buffer without advancing the index pointer. |
| public int | read()
Implements abstract java. Reads the next byte of data from the input stream. |
| public int | read(byte[]
the buffer into which the data is read. to, int the start offset in array off, int b
at which the data is written.the maximum number of bytes to read. len)Overrides java. Reads up to |
| private boolean | Returns: True if at least some bytes were read.How much should be at least read. wanted, boolean block)Reads more bytes into the buffer. |
| public byte | |
| public int | Returns: The length of the next null terminated string.Scans the length of the next null terminated string (C-style string) from the stream. |
| public void | |
| public long | skip(long
the number of bytes to be skipped. n)Overrides java. Skips over and discards |
| buffer | back to summary |
|---|---|
| private byte[] buffer The buffer. | |
| endIndex | back to summary |
|---|---|
| private int endIndex How far is the buffer filled with valid data. | |
| index | back to summary |
|---|---|
| private int index Current read position in the buffer. | |
| MINIMUM_READ | back to summary |
|---|---|
| private static final int MINIMUM_READ If a direct read to byte array is called that would require a smaller read from the wrapped stream that MINIMUM_READ then first fill the buffer and serve the bytes from there. Larger reads are directly done to the provided byte array. | |
| STRING_SCAN_SPAN | back to summary |
|---|---|
| private static final int STRING_SCAN_SPAN In how large spans is the C string zero-byte scanned. | |
| timeoutRequested | back to summary |
|---|---|
| private boolean timeoutRequested socket timeout has been requested | |
| wrapped | back to summary |
|---|---|
| private final InputStream wrapped The wrapped input stream. | |
| VisibleBufferedInputStream | back to summary |
|---|---|
| public VisibleBufferedInputStream(InputStream in, int bufferSize) Creates a new buffer around the given stream.
| |
| available | back to summary |
|---|---|
| public int available() throws IOException Overrides java. Doc from java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. Note that while some implementations of A subclass's implementation of this method may choose to throw an
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| compact | back to summary |
|---|---|
| private void compact() Compacts the unread bytes of the buffer to the beginning of the buffer. | |
| doubleBuffer | back to summary |
|---|---|
| private void doubleBuffer() Doubles the size of the buffer. | |
| ensureBytes | back to summary |
|---|---|
| public boolean ensureBytes(int n) throws IOException Ensures that the buffer contains at least n bytes. This method invalidates the buffer and index fields.
| |
| ensureBytes | back to summary |
|---|---|
| public boolean ensureBytes(int n, boolean block) throws IOException Ensures that the buffer contains at least n bytes. This method invalidates the buffer and index fields.
| |
| getBuffer | back to summary |
|---|---|
| public byte[] getBuffer() Returns direct handle to the used buffer. Use the
| |
| getIndex | back to summary |
|---|---|
| public int getIndex() Returns the current read position in the buffer.
| |
| getWrapped | back to summary |
|---|---|
public InputStream getWrapped()
| |
| moveBufferTo | back to summary |
|---|---|
| private void moveBufferTo(byte[] dest) Moves bytes from the buffer to the beginning of the destination buffer. Also sets the index and endIndex variables.
| |
| peek | back to summary |
|---|---|
| public int peek() throws IOException Reads a byte from the buffer without advancing the index pointer.
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(byte[] to, int off, int len) throws IOException Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |
| readMore | back to summary |
|---|---|
| private boolean readMore(int wanted, boolean block) throws IOException Reads more bytes into the buffer.
| |
| readRaw | back to summary |
|---|---|
| public byte readRaw() Reads byte from the buffer without any checks. This method never reads from the underlaying
stream. Before calling this method the
| |
| scanCStringLength | back to summary |
|---|---|
| public int scanCStringLength() throws IOException Scans the length of the next null terminated string (C-style string) from the stream.
| |
| setTimeoutRequested | back to summary |
|---|---|
| public void setTimeoutRequested(boolean timeoutRequested) | |
| skip | back to summary |
|---|---|
| public long skip(long n) throws IOException Overrides java. Doc from java. Skips over and discards
| |