public class ReadAheadBufferedStream
extends java.io.FilterInputStream
Modifier and Type | Field and Description |
---|---|
private byte[] |
buf |
private static int |
BUF_SIZE |
private int |
end |
private int |
pos |
Constructor and Description |
---|
ReadAheadBufferedStream(java.io.InputStream in) |
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close() |
private void |
fillBuffer(int minNeededBytes)
Fill buffer with required length, or available bytes.
|
boolean |
markSupported() |
int |
read()
Reading one byte from cache of socket if needed.
|
int |
read(byte[] externalBuf,
int off,
int len)
Returing byte array, from cache of reading socket if needed.
|
void |
reset() |
long |
skip(long n) |
private volatile byte[] buf
private int end
private int pos
private static final int BUF_SIZE
public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
- if socket reading error.public int read(byte[] externalBuf, int off, int len) throws java.io.IOException
read
in class java.io.FilterInputStream
externalBuf
- buffer to filloff
- offsetlen
- length to readjava.io.IOException
- if exception during socket readingprivate void fillBuffer(int minNeededBytes) throws java.io.IOException
minNeededBytes
- asked number of bytesjava.io.IOException
- in case of failing reading stream.public long skip(long n) throws java.io.IOException
skip
in class java.io.FilterInputStream
java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.FilterInputStream
java.io.IOException
public void reset() throws java.io.IOException
reset
in class java.io.FilterInputStream
java.io.IOException
public boolean markSupported()
markSupported
in class java.io.FilterInputStream
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.FilterInputStream
java.io.IOException