com.sleepycat.util

Class FastInputStream

public class FastInputStream extends InputStream

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
protected byte[]buf
protected intlen
protected intmark
protected intoff
Constructor Summary
FastInputStream(byte[] buffer)
Creates an input stream.
FastInputStream(byte[] buffer, int offset, int length)
Creates an input stream.
Method Summary
intavailable()
byte[]getBufferBytes()
Returns the underlying data being read.
intgetBufferLength()
Returns the end of the buffer being read.
intgetBufferOffset()
Returns the offset at which data is being read from the buffer.
voidmark(int readLimit)
booleanmarkSupported()
intread()
intread(byte[] toBuf)
intread(byte[] toBuf, int offset, int length)
intreadFast()
Equivalent to read() but does not throw IOException.
intreadFast(byte[] toBuf)
Equivalent to read(byte[]) but does not throw IOException.
intreadFast(byte[] toBuf, int offset, int length)
Equivalent to read(byte[],int,int) but does not throw IOException.
voidreset()
longskip(long count)
voidskipFast(int count)
Equivalent to skip() 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.

Field Detail

buf

protected byte[] buf

len

protected int len

mark

protected int mark

off

protected int off

Constructor Detail

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 Detail

available

public int available()

getBufferBytes

public final byte[] getBufferBytes()
Returns the underlying data being read.

Returns: the underlying data.

getBufferLength

public final int getBufferLength()
Returns the end of the buffer being read.

Returns: the end of the buffer.

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.

mark

public void mark(int readLimit)

markSupported

public boolean markSupported()

read

public int read()

read

public int read(byte[] toBuf)

read

public int read(byte[] toBuf, int offset, int length)

readFast

public final int readFast()
Equivalent to read() but does not throw IOException.

See Also: read

readFast

public final int readFast(byte[] toBuf)
Equivalent to read(byte[]) but does not throw IOException.

See Also: (byte[])

readFast

public final int readFast(byte[] toBuf, int offset, int length)
Equivalent to read(byte[],int,int) but does not throw IOException.

See Also: (byte[],int,int)

reset

public void reset()

skip

public long skip(long count)

skipFast

public final void skipFast(int count)
Equivalent to skip() 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: FastInputStream