public class ByteBufInputStream extends InputStream implements DataInput
InputStream which reads data from a ByteBuf.
A read operation against this stream will occur at the readerIndex
of its underlying buffer and the readerIndex will increase during
the read operation. Please note that it only reads up to the number of
readable bytes determined at the moment of construction. Therefore,
updating ByteBuf.writerIndex() will not affect the return
value of available().
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.
ByteBufOutputStream| Constructor and Description |
|---|
ByteBufInputStream(ByteBuf buffer)
Creates a new stream which reads data from the specified
buffer
starting at the current readerIndex and ending at the current
writerIndex. |
ByteBufInputStream(ByteBuf buffer,
boolean releaseOnClose)
Creates a new stream which reads data from the specified
buffer
starting at the current readerIndex and ending at the current
writerIndex. |
ByteBufInputStream(ByteBuf buffer,
int length)
Creates a new stream which reads data from the specified
buffer
starting at the current readerIndex and ending at
readerIndex + length. |
ByteBufInputStream(ByteBuf buffer,
int length,
boolean releaseOnClose)
Creates a new stream which reads data from the specified
buffer
starting at the current readerIndex and ending at
readerIndex + length. |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
boolean |
readBoolean() |
byte |
readByte() |
int |
readBytes()
Returns the number of read bytes by this stream so far.
|
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
String |
readLine() |
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
String |
readUTF() |
void |
reset() |
long |
skip(long n) |
int |
skipBytes(int n) |
readpublic ByteBufInputStream(ByteBuf buffer)
buffer
starting at the current readerIndex and ending at the current
writerIndex.buffer - The buffer which provides the content for this InputStream.public ByteBufInputStream(ByteBuf buffer, int length)
buffer
starting at the current readerIndex and ending at
readerIndex + length.buffer - The buffer which provides the content for this InputStream.length - The length of the buffer to use for this InputStream.IndexOutOfBoundsException - if readerIndex + length is greater than
writerIndexpublic ByteBufInputStream(ByteBuf buffer, boolean releaseOnClose)
buffer
starting at the current readerIndex and ending at the current
writerIndex.buffer - The buffer which provides the content for this InputStream.releaseOnClose - true means that when close() is called then ReferenceCounted.release() will
be called on buffer.public ByteBufInputStream(ByteBuf buffer, int length, boolean releaseOnClose)
buffer
starting at the current readerIndex and ending at
readerIndex + length.buffer - The buffer which provides the content for this InputStream.length - The length of the buffer to use for this InputStream.releaseOnClose - true means that when close() is called then ReferenceCounted.release() will
be called on buffer.IndexOutOfBoundsException - if readerIndex + length is greater than
writerIndexpublic int readBytes()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic int available()
throws IOException
available in class InputStreamIOExceptionpublic void mark(int readlimit)
mark in class InputStreampublic boolean markSupported()
markSupported in class InputStreampublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic void reset()
throws IOException
reset in class InputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic boolean readBoolean()
throws IOException
readBoolean in interface DataInputIOExceptionpublic byte readByte()
throws IOException
readByte in interface DataInputIOExceptionpublic char readChar()
throws IOException
readChar in interface DataInputIOExceptionpublic double readDouble()
throws IOException
readDouble in interface DataInputIOExceptionpublic float readFloat()
throws IOException
readFloat in interface DataInputIOExceptionpublic void readFully(byte[] b)
throws IOException
readFully in interface DataInputIOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws IOException
readFully in interface DataInputIOExceptionpublic int readInt()
throws IOException
readInt in interface DataInputIOExceptionpublic String readLine() throws IOException
readLine in interface DataInputIOExceptionpublic long readLong()
throws IOException
readLong in interface DataInputIOExceptionpublic short readShort()
throws IOException
readShort in interface DataInputIOExceptionpublic String readUTF() throws IOException
readUTF in interface DataInputIOExceptionpublic int readUnsignedByte()
throws IOException
readUnsignedByte in interface DataInputIOExceptionpublic int readUnsignedShort()
throws IOException
readUnsignedShort in interface DataInputIOExceptionpublic int skipBytes(int n)
throws IOException
skipBytes in interface DataInputIOExceptionCopyright © 2008–2025 The Netty Project. All rights reserved.