public class StaticBufferedInputStream
extends java.io.InputStream
BufferedInputStream, but is not thread-safe and
also uses a a re-usable static buffer provided by StaticBuffers to
achieve better performance| Modifier and Type | Field and Description |
|---|---|
protected java.nio.ByteBuffer |
_byteBuffer
A re-usable buffer
|
protected int |
_count
The number of bytes in the buffer
|
protected java.io.InputStream |
_in
The original unbuffered input stream
|
protected int |
_mark
The current marked position.
|
protected int |
_pos
The current read position
|
protected byte[] |
_raw
The raw re-usable buffer
|
protected StaticBuffers |
_staticBuffers
Provides re-usable buffers
|
protected static StaticBuffers.Key |
BUFFER_KEY
A unique key for the re-usable buffer
|
| Constructor and Description |
|---|
StaticBufferedInputStream(java.io.InputStream in)
Creates a new buffered input stream
|
StaticBufferedInputStream(java.io.InputStream in,
int size)
Creates a new buffered input stream
|
protected static final StaticBuffers.Key BUFFER_KEY
protected final StaticBuffers _staticBuffers
protected final java.nio.ByteBuffer _byteBuffer
protected final byte[] _raw
protected final java.io.InputStream _in
protected int _pos
protected int _count
protected int _mark
public StaticBufferedInputStream(java.io.InputStream in)
in - the original unbuffered input streampublic StaticBufferedInputStream(java.io.InputStream in,
int size)
in - the original unbuffered input streamsize - the minimum buffer sizepublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionprotected void fill()
throws java.io.IOException
java.io.IOExceptionpublic int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic int read(byte[] b,
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 boolean markSupported()
markSupported in class java.io.InputStreampublic void mark(int marklimit)
mark in class java.io.InputStreampublic void reset()
throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOException