public class InStream extends Object
| Constructor and Description |
|---|
InStream(byte[] data)
Creates a new buffered input stream based on the given byte array.
|
InStream(byte[] data,
Duration readDuration)
Creates a new buffered input stream based on the given byte array.
|
InStream(byte[] data,
int offset,
int length)
Creates a new buffered input stream based on the section in the given byte array.
|
InStream(byte[] data,
int offset,
int length,
Duration readDuration)
Creates a new buffered input stream based on the section in the given byte array.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Calculates the amount of bytes still remaining to read on the stream.
|
Optional<Duration> |
getReadDuration()
Gets the duration it took to read this message.
|
void |
mark()
Marks the current position.
|
void |
moveBack(int n)
Moves the read pointer back with
n position. |
boolean |
readBoolean()
Reads a boolean value from the stream.
|
byte |
readByte()
Reads a signed byte from the stream.
|
char |
readChar()
Reads a character from the stream.
|
void |
readFully(byte[] b)
Fills the given byte array with data read from the stream.
|
void |
readFully(byte[] b,
int off,
int len)
Fills the given section of the byte array with data read from the stream.
|
byte[] |
readFully(int length)
Reads
length bytes into a new byte array. |
int |
readInt()
Reads an integer from the stream.
|
long |
readLong()
Reads a long from the stream.
|
short |
readShort()
Reads a short from the stream.
|
String |
readString(int length)
Reads a string from the stream.
|
int |
readUnsignedByte()
Reads an unsigned byte from the stream.
|
int |
readUnsignedShort()
Reads an unsigned short from the stream.
|
void |
resetToMark()
Returns to the last marked position with
mark() or 0 if no mark has happened before. |
int |
skipBytes(int n)
Skips the next
n bytes on the stream. |
public InStream(byte[] data)
InStream(data, 0, data.length, null).data - The byte bufferInStream(byte[], int, int)public InStream(byte[] data,
Duration readDuration)
InStream(data, 0, data.length, readDuration).data - The byte bufferreadDuration - The duration it took to read the given bufferInStream(byte[], int, int, Duration)public InStream(byte[] data,
int offset,
int length)
data - The byte bufferoffset - The starting offsetlength - The amount of bytes availableInStream(byte[], int, int, Duration)public InStream(byte[] data,
int offset,
int length,
Duration readDuration)
data - The byte bufferoffset - The starting offsetlength - The amount of bytes availablereadDuration - The duration it took to read the given bufferpublic boolean readBoolean()
true when the read byte is not zero.public byte readByte()
public char readChar()
public void readFully(byte[] b)
b - The byte buffer to copy the data to.public void readFully(byte[] b,
int off,
int len)
b - The byte buffer to copy the data to.off - The starting offset.len - The amount of bytes to copy.public byte[] readFully(int length)
length bytes into a new byte array.length - The amount of bytes to readpublic int readInt()
public long readLong()
public short readShort()
public int readUnsignedByte()
public int readUnsignedShort()
public int skipBytes(int n)
n bytes on the stream.n - The amount of bytes to skippublic void moveBack(int n)
n position.
This method cannot be combined with mark() on the same stream as this method assumes the marked position to be 0.n - The amount of bytes to 'unread'mark()public int available()
public String readString(int length)
length - The amount of characters in the stringpublic void mark()
public void resetToMark()
mark() or 0 if no mark has happened before.public Optional<Duration> getReadDuration()
Optional.empty() if unknownCopyright © 2016. All rights reserved.