Package org.jboss.netty.buffer
Class ChannelBufferInputStream
java.lang.Object
java.io.InputStream
org.jboss.netty.buffer.ChannelBufferInputStream
- All Implemented Interfaces:
Closeable
,DataInput
,AutoCloseable
An
InputStream
which reads data from a ChannelBuffer
.
A read operation against this stream will occur at the readerIndex
of its underlying buffer and the readerIndex
will increase during
the read operation.
This stream implements DataInput
for your convenience.
The endianness of the stream is not always big endian but depends on
the endianness of the underlying buffer.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChannelBuffer
private final int
private final StringBuilder
private final int
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new stream which reads data from the specifiedbuffer
starting at the currentreaderIndex
and ending at the currentwriterIndex
.ChannelBufferInputStream
(ChannelBuffer buffer, int length) Creates a new stream which reads data from the specifiedbuffer
starting at the currentreaderIndex
and ending atreaderIndex + length
. -
Method Summary
Modifier and TypeMethodDescriptionint
private void
checkAvailable
(int fieldSize) void
mark
(int readlimit) boolean
int
read()
int
read
(byte[] b, int off, int len) boolean
byte
readByte()
int
Returns the number of read bytes by this stream so far.char
readChar()
double
float
void
readFully
(byte[] b) void
readFully
(byte[] b, int off, int len) int
readInt()
readLine()
long
readLong()
short
int
int
readUTF()
void
reset()
long
skip
(long n) int
skipBytes
(int n) Methods inherited from class java.io.InputStream
close, read
-
Field Details
-
buffer
-
startIndex
private final int startIndex -
endIndex
private final int endIndex -
lineBuf
-
-
Constructor Details
-
ChannelBufferInputStream
Creates a new stream which reads data from the specifiedbuffer
starting at the currentreaderIndex
and ending at the currentwriterIndex
. -
ChannelBufferInputStream
Creates a new stream which reads data from the specifiedbuffer
starting at the currentreaderIndex
and ending atreaderIndex + length
.- Throws:
IndexOutOfBoundsException
- ifreaderIndex + length
is greater thanwriterIndex
-
-
Method Details
-
readBytes
public int readBytes()Returns the number of read bytes by this stream so far. -
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
mark
in classInputStream
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
reset
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
readBoolean
- Specified by:
readBoolean
in interfaceDataInput
- Throws:
IOException
-
readByte
- Specified by:
readByte
in interfaceDataInput
- Throws:
IOException
-
readChar
- Specified by:
readChar
in interfaceDataInput
- Throws:
IOException
-
readDouble
- Specified by:
readDouble
in interfaceDataInput
- Throws:
IOException
-
readFloat
- Specified by:
readFloat
in interfaceDataInput
- Throws:
IOException
-
readFully
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readFully
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readInt
- Specified by:
readInt
in interfaceDataInput
- Throws:
IOException
-
readLine
- Specified by:
readLine
in interfaceDataInput
- Throws:
IOException
-
readLong
- Specified by:
readLong
in interfaceDataInput
- Throws:
IOException
-
readShort
- Specified by:
readShort
in interfaceDataInput
- Throws:
IOException
-
readUTF
- Specified by:
readUTF
in interfaceDataInput
- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedByte
in interfaceDataInput
- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShort
in interfaceDataInput
- Throws:
IOException
-
skipBytes
- Specified by:
skipBytes
in interfaceDataInput
- Throws:
IOException
-
checkAvailable
- Throws:
IOException
-