public class VisibleBufferedInputStream
extends java.io.InputStream
| Constructor and Description |
|---|
VisibleBufferedInputStream(java.io.InputStream in,
int bufferSize)
Creates a new buffer around the given stream.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
boolean |
ensureBytes(int n)
Ensures that the buffer contains at least n bytes.
|
byte[] |
getBuffer()
Returns direct handle to the used buffer.
|
int |
getIndex()
Returns the current read position in the buffer.
|
int |
peek()
Reads a byte from the buffer without advancing the index pointer.
|
int |
read() |
int |
read(byte[] to,
int off,
int len) |
byte |
readRaw()
Reads byte from the buffer without any checks.
|
int |
scanCStringLength()
Scans the length of the next null terminated string (C-style string) from the stream.
|
long |
skip(long n) |
public VisibleBufferedInputStream(java.io.InputStream in,
int bufferSize)
in - The stream to buffer.bufferSize - The initial size of the buffer.public int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic int peek()
throws java.io.IOException
java.io.IOException - if something wrong happenspublic byte readRaw()
ensureBytes(int) method must have been called.java.lang.ArrayIndexOutOfBoundsException - If ensureBytes was not called to make sure the buffer
contains the byte.public boolean ensureBytes(int n)
throws java.io.IOException
n - The amount of bytes to ensure exists in bufferjava.io.IOException - If reading of the wrapped stream failed.public int read(byte[] to,
int off,
int len)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic long skip(long n)
throws java.io.IOException
skip in class java.io.InputStreamjava.io.IOExceptionpublic int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionpublic byte[] getBuffer()
ensureBytes(int) to prefill required
bytes the buffer and getIndex() to fetch the current position of the buffer.public int getIndex()
public int scanCStringLength()
throws java.io.IOException
java.io.IOException - If reading of stream fails.java.io.EOFException - If the stream did not contain any null terminators.Copyright © 2021 PostgreSQL Global Development Group. All rights reserved.