uk.ac.starlink.util
Class HeadBufferInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
uk.ac.starlink.util.HeadBufferInputStream
- All Implemented Interfaces:
- java.io.Closeable
public class HeadBufferInputStream
- extends java.io.FilterInputStream
Filter input stream that records the first few bytes read from
its base stream for later examination.
- Since:
- 5 Aug 2015
Fields inherited from class java.io.FilterInputStream |
in |
Method Summary |
byte[] |
getHeadBuffer()
Returns the actual buffer used for accumulating the first few bytes
in the stream. |
int |
getReadCount()
Returns the total number of bytes so far read from the base stream. |
void |
mark(int readlimit)
|
boolean |
markSupported()
Mark/reset is not supported. |
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
void |
reset()
|
long |
skip(long n)
|
Methods inherited from class java.io.FilterInputStream |
available, close |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HeadBufferInputStream
public HeadBufferInputStream(java.io.InputStream in,
int headSize)
- Constructor.
- Parameters:
in
- base input streamheadSize
- size of head buffer
getHeadBuffer
public byte[] getHeadBuffer()
- Returns the actual buffer used for accumulating the first few bytes
in the stream. If the read count is lower than the size of this
buffer, not all the buffer has been filled.
- Returns:
- buffer, same length as size supplied at construction time
getReadCount
public int getReadCount()
- Returns the total number of bytes so far read from the base stream.
- Returns:
- byte read count
read
public int read()
throws java.io.IOException
- Overrides:
read
in class java.io.FilterInputStream
- Throws:
java.io.IOException
read
public int read(byte[] b)
throws java.io.IOException
- Overrides:
read
in class java.io.FilterInputStream
- Throws:
java.io.IOException
read
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
- Overrides:
read
in class java.io.FilterInputStream
- Throws:
java.io.IOException
skip
public long skip(long n)
throws java.io.IOException
- Overrides:
skip
in class java.io.FilterInputStream
- Throws:
java.io.IOException
markSupported
public boolean markSupported()
- Mark/reset is not supported.
- Overrides:
markSupported
in class java.io.FilterInputStream
reset
public void reset()
throws java.io.IOException
- Overrides:
reset
in class java.io.FilterInputStream
- Throws:
java.io.IOException
mark
public void mark(int readlimit)
- Overrides:
mark
in class java.io.FilterInputStream