Package org.apache.activemq.util
Class DataByteArrayInputStream
java.lang.Object
java.io.InputStream
org.apache.activemq.util.DataByteArrayInputStream
- All Implemented Interfaces:
Closeable
,DataInput
,AutoCloseable
Optimized ByteArrayInputStream that can be used more than once
-
Constructor Summary
ConstructorDescriptionCreatesWireByteArrayInputStream
with a minmalist byte arrayDataByteArrayInputStream
(byte[] buf) Creates aStoreByteArrayInputStream
.DataByteArrayInputStream
(ByteSequence sequence) Creates aStoreByteArrayInputStream
. -
Method Summary
Modifier and TypeMethodDescriptionint
byte[]
int
position()
int
read()
Reads the next byte of data from this input stream.int
read
(byte[] b, int off, int len) Reads up tolen
bytes of data into an array of bytes from this input stream.boolean
byte
readByte()
char
readChar()
double
float
void
readFully
(byte[] b) void
readFully
(byte[] b, int off, int len) int
readInt()
readLine()
long
readLong()
int
short
int
int
readUTF()
void
restart
(byte[] newBuff) reset theStoreByteArrayInputStream
to use an new byte arrayvoid
restart
(int size) re-start the input stream - reusing the current buffervoid
restart
(ByteSequence sequence) reset theStoreByteArrayInputStream
to use an new ByteSequenceint
size()
int
skipBytes
(int n) Methods inherited from class java.io.InputStream
close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
DataByteArrayInputStream
public DataByteArrayInputStream(byte[] buf) Creates aStoreByteArrayInputStream
.- Parameters:
buf
- the input buffer.
-
DataByteArrayInputStream
Creates aStoreByteArrayInputStream
.- Parameters:
sequence
- the input buffer.
-
DataByteArrayInputStream
public DataByteArrayInputStream()CreatesWireByteArrayInputStream
with a minmalist byte array
-
-
Method Details
-
size
public int size()- Returns:
- the size
-
position
public int position() -
getRawData
public byte[] getRawData()- Returns:
- the underlying data array
-
restart
public void restart(byte[] newBuff) reset theStoreByteArrayInputStream
to use an new byte array- Parameters:
newBuff
-
-
restart
reset theStoreByteArrayInputStream
to use an new ByteSequence- Parameters:
sequence
-
-
restart
public void restart(int size) re-start the input stream - reusing the current buffer- Parameters:
size
-
-
read
public int read()Reads the next byte of data from this input stream. The value byte is returned as anint
in the range0
to255
. If no byte is available because the end of the stream has been reached, the value-1
is returned.This
read
method cannot block.- Specified by:
read
in classInputStream
- Returns:
- the next byte of data, or
-1
if the end of the stream has been reached.
-
readOrIOException
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) Reads up tolen
bytes of data into an array of bytes from this input stream.- Overrides:
read
in classInputStream
- Parameters:
b
- the buffer into which the data is read.off
- the start offset of the data.len
- the maximum number of bytes read.- Returns:
- the total number of bytes read into the buffer, or
-1
if there is no more data because the end of the stream has been reached.
-
available
public int available()- Overrides:
available
in classInputStream
- Returns:
- the number of bytes that can be read from the input stream without blocking.
-
readFully
public void readFully(byte[] b) -
readFully
public void readFully(byte[] b, int off, int len) -
skipBytes
public int skipBytes(int n) -
readBoolean
- Specified by:
readBoolean
in interfaceDataInput
- Throws:
IOException
-
readByte
- Specified by:
readByte
in interfaceDataInput
- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedByte
in interfaceDataInput
- Throws:
IOException
-
readShort
- Specified by:
readShort
in interfaceDataInput
- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShort
in interfaceDataInput
- Throws:
IOException
-
readChar
- Specified by:
readChar
in interfaceDataInput
- Throws:
IOException
-
readInt
- Specified by:
readInt
in interfaceDataInput
- Throws:
IOException
-
readLong
- Specified by:
readLong
in interfaceDataInput
- Throws:
IOException
-
readFloat
- Specified by:
readFloat
in interfaceDataInput
- Throws:
IOException
-
readDouble
- Specified by:
readDouble
in interfaceDataInput
- Throws:
IOException
-
readLine
-
readUTF
- Specified by:
readUTF
in interfaceDataInput
- Throws:
IOException
-