Class HeadBufferInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
uk.ac.starlink.util.HeadBufferInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
Filter input stream that records the first few bytes read from
its base stream for later examination.
- Since:
- 5 Aug 2015
- Author:
- Mark Taylor
-
Field Summary
Fields inherited from class FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Returns the actual buffer used for accumulating the first few bytes in the stream.longReturns the total number of bytes so far read from the base stream.voidmark(int readlimit) booleanMark/reset is not supported.intread()intread(byte[] b) intread(byte[] b, int off, int len) voidreset()longskip(long n) Methods inherited from class FilterInputStream
available, closeMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
HeadBufferInputStream
Constructor.- Parameters:
in- base input streamheadSize- size of head buffer
-
-
Method Details
-
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 long getReadCount()Returns the total number of bytes so far read from the base stream.- Returns:
- byte read count
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()Mark/reset is not supported.- Overrides:
markSupportedin classFilterInputStream
-
reset
- Overrides:
resetin classFilterInputStream- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
markin classFilterInputStream
-