Package com.sleepycat.util
Class FastInputStream
java.lang.Object
java.io.InputStream
com.sleepycat.util.FastInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
TupleInput
A replacement for ByteArrayInputStream that does not synchronize every
byte read.
This class extends InputStream and its read()
methods allow it to be used as a standard input stream. In addition, it
provides readFast() methods that are not declared to throw
IOException. IOException is never thrown by this
class.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFastInputStream(byte[] buffer) Creates an input stream.FastInputStream(byte[] buffer, int offset, int length) Creates an input stream. -
Method Summary
Modifier and TypeMethodDescriptionintfinal byte[]Returns the underlying data being read.final intReturns the end of the buffer being read.final intReturns the offset at which data is being read from the buffer.voidmark(int readLimit) booleanintread()intread(byte[] toBuf) intread(byte[] toBuf, int offset, int length) final intreadFast()Equivalent toread()but does not throwIOException.final intreadFast(byte[] toBuf) Equivalent toread(byte[])but does not throwIOException.final intreadFast(byte[] toBuf, int offset, int length) Equivalent toread(byte[],int,int)but does not throwIOException.voidreset()longskip(long count) final voidskipFast(int count) Equivalent toskip()but takes an int parameter instead of a long, and does not check whether the count given is larger than the number of remaining bytes.Methods inherited from class java.io.InputStream
close, nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
len
protected int len -
off
protected int off -
mark
protected int mark -
buf
protected byte[] buf
-
-
Constructor Details
-
FastInputStream
public FastInputStream(byte[] buffer) Creates an input stream.- Parameters:
buffer- the data to read.
-
FastInputStream
public FastInputStream(byte[] buffer, int offset, int length) Creates an input stream.- Parameters:
buffer- the data to read.offset- the byte offset at which to begin reading.length- the number of bytes to read.
-
-
Method Details
-
available
public int available()- Overrides:
availablein classInputStream
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
mark
public void mark(int readLimit) - Overrides:
markin classInputStream
-
reset
public void reset()- Overrides:
resetin classInputStream
-
skip
public long skip(long count) - Overrides:
skipin classInputStream
-
read
public int read()- Specified by:
readin classInputStream
-
read
public int read(byte[] toBuf) - Overrides:
readin classInputStream
-
read
public int read(byte[] toBuf, int offset, int length) - Overrides:
readin classInputStream
-
skipFast
public final void skipFast(int count) Equivalent toskip()but takes an int parameter instead of a long, and does not check whether the count given is larger than the number of remaining bytes.- See Also:
-
readFast
public final int readFast()Equivalent toread()but does not throwIOException.- See Also:
-
readFast
public final int readFast(byte[] toBuf) Equivalent toread(byte[])but does not throwIOException.- See Also:
-
readFast
public final int readFast(byte[] toBuf, int offset, int length) Equivalent toread(byte[],int,int)but does not throwIOException.- See Also:
-
getBufferBytes
public final byte[] getBufferBytes()Returns the underlying data being read.- Returns:
- the underlying data.
-
getBufferOffset
public final int getBufferOffset()Returns the offset at which data is being read from the buffer.- Returns:
- the offset at which data is being read.
-
getBufferLength
public final int getBufferLength()Returns the end of the buffer being read.- Returns:
- the end of the buffer.
-