|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
org.postgresql.core.VisibleBufferedInputStream
public class VisibleBufferedInputStream
A faster version of BufferedInputStream. Does no synchronisation and allows direct access to the used byte[] buffer.
Constructor Summary | |
---|---|
VisibleBufferedInputStream(InputStream in,
int bufferSize)
Creates a new buffer around the given stream. |
Method Summary | |
---|---|
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)
|
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, read, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VisibleBufferedInputStream(InputStream in, int bufferSize)
in
- The stream to buffer.bufferSize
- The initial size of the buffer.Method Detail |
---|
public int read() throws IOException
read
in class InputStream
IOException
public int peek() throws IOException
IOException
- if something wrong happenspublic byte readRaw()
ensureBytes(int)
method must have been called.
ArrayIndexOutOfBoundsException
- If ensureBytes was not called to make sure the buffer
contains the byte.public boolean ensureBytes(int n) throws IOException
n
- The amount of bytes to ensure exists in buffer
IOException
- If reading of the wrapped stream failed.public int read(byte[] to, int off, int len) throws IOException
read
in class InputStream
IOException
public long skip(long n) throws IOException
skip
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
public 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 IOException
IOException
- If reading of stream fails.
EOFException
- If the stream did not contain any null terminators.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |