Package org.apache.activemq.util
Class DataByteArrayInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.activemq.util.DataByteArrayInputStream
-
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable
public final class DataByteArrayInputStream extends InputStream implements DataInput
Optimized ByteArrayInputStream that can be used more than once
-
-
Constructor Summary
Constructors Constructor Description DataByteArrayInputStream()CreatesWireByteArrayInputStreamwith a minmalist byte arrayDataByteArrayInputStream(byte[] buf)Creates aStoreByteArrayInputStream.DataByteArrayInputStream(ByteSequence sequence)Creates aStoreByteArrayInputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()byte[]getRawData()intposition()intread()Reads the next byte of data from this input stream.intread(byte[] b, int off, int len)Reads up tolenbytes of data into an array of bytes from this input stream.booleanreadBoolean()bytereadByte()charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()StringreadLine()longreadLong()intreadOrIOException()shortreadShort()intreadUnsignedByte()intreadUnsignedShort()StringreadUTF()voidrestart(byte[] newBuff)reset theStoreByteArrayInputStreamto use an new byte arrayvoidrestart(int size)re-start the input stream - reusing the current buffervoidrestart(ByteSequence sequence)reset theStoreByteArrayInputStreamto use an new ByteSequenceintsize()intskipBytes(int n)-
Methods inherited from class java.io.InputStream
close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
DataByteArrayInputStream
public DataByteArrayInputStream(byte[] buf)
Creates aStoreByteArrayInputStream.- Parameters:
buf- the input buffer.
-
DataByteArrayInputStream
public DataByteArrayInputStream(ByteSequence sequence)
Creates aStoreByteArrayInputStream.- Parameters:
sequence- the input buffer.
-
DataByteArrayInputStream
public DataByteArrayInputStream()
CreatesWireByteArrayInputStreamwith a minmalist byte array
-
-
Method Detail
-
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 theStoreByteArrayInputStreamto use an new byte array- Parameters:
newBuff-
-
restart
public void restart(ByteSequence sequence)
reset theStoreByteArrayInputStreamto 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 anintin the range0to255. If no byte is available because the end of the stream has been reached, the value-1is returned.This
readmethod cannot block.- Specified by:
readin classInputStream- Returns:
- the next byte of data, or
-1if the end of the stream has been reached.
-
readOrIOException
public int readOrIOException() throws IOException- Throws:
IOException
-
read
public int read(byte[] b, int off, int len)Reads up tolenbytes of data into an array of bytes from this input stream.- Overrides:
readin 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
-1if there is no more data because the end of the stream has been reached.
-
available
public int available()
- Overrides:
availablein classInputStream- Returns:
- the number of bytes that can be read from the input stream without blocking.
-
readFully
public void readFully(byte[] b, int off, int len)
-
readBoolean
public boolean readBoolean() throws IOException- Specified by:
readBooleanin interfaceDataInput- Throws:
IOException
-
readByte
public byte readByte() throws IOException- Specified by:
readBytein interfaceDataInput- Throws:
IOException
-
readUnsignedByte
public int readUnsignedByte() throws IOException- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
IOException
-
readShort
public short readShort() throws IOException- Specified by:
readShortin interfaceDataInput- Throws:
IOException
-
readUnsignedShort
public int readUnsignedShort() throws IOException- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
IOException
-
readChar
public char readChar() throws IOException- Specified by:
readCharin interfaceDataInput- Throws:
IOException
-
readInt
public int readInt() throws IOException- Specified by:
readIntin interfaceDataInput- Throws:
IOException
-
readLong
public long readLong() throws IOException- Specified by:
readLongin interfaceDataInput- Throws:
IOException
-
readFloat
public float readFloat() throws IOException- Specified by:
readFloatin interfaceDataInput- Throws:
IOException
-
readDouble
public double readDouble() throws IOException- Specified by:
readDoublein interfaceDataInput- Throws:
IOException
-
readUTF
public String readUTF() throws IOException
- Specified by:
readUTFin interfaceDataInput- Throws:
IOException
-
-