- java.lang.Object
-
- java.io.InputStream
-
- io.netty5.buffer.BufferInputStream
-
- All Implemented Interfaces:
Closeable
,DataInput
,AutoCloseable
public final class BufferInputStream extends InputStream implements DataInput
AnInputStream
which reads data from aBuffer
.A read operation against this stream will occur at the
readerOffset
of its underlying buffer and thereaderOffset
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, updatingBuffer.writerOffset()
will not affect the return value ofavailable()
.This stream implements
DataInput
for your convenience. The endianness of the stream is always big endian.- See Also:
BufferOutputStream
-
-
Constructor Summary
Constructors Constructor Description BufferInputStream(Send<Buffer> buffer)
Creates a new stream which reads data from the specifiedbuffer
starting at the currentreaderOffset
and ending at the currentwriterOffset
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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)
-
Methods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
BufferInputStream
public BufferInputStream(Send<Buffer> buffer)
Creates a new stream which reads data from the specifiedbuffer
starting at the currentreaderOffset
and ending at the currentwriterOffset
.When this
BufferInputStream
is closed, then the sent buffer will also be closed.- Parameters:
buffer
- The buffer which provides the content for thisInputStream
.
-
-
Method Detail
-
readBytes
public int readBytes()
Returns the number of read bytes by this stream so far.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
available
public int available() throws IOException
- 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
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
reset
public void reset() throws IOException
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
skip
public long skip(long n) throws IOException
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
readBoolean
public boolean readBoolean() throws IOException
- Specified by:
readBoolean
in interfaceDataInput
- Throws:
IOException
-
readByte
public byte readByte() throws IOException
- Specified by:
readByte
in interfaceDataInput
- Throws:
IOException
-
readChar
public char readChar() throws IOException
- Specified by:
readChar
in interfaceDataInput
- Throws:
IOException
-
readDouble
public double readDouble() throws IOException
- Specified by:
readDouble
in interfaceDataInput
- Throws:
IOException
-
readFloat
public float readFloat() throws IOException
- Specified by:
readFloat
in interfaceDataInput
- Throws:
IOException
-
readFully
public void readFully(byte[] b) throws IOException
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws IOException
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readInt
public int readInt() throws IOException
- Specified by:
readInt
in interfaceDataInput
- Throws:
IOException
-
readLine
public String readLine() throws IOException
- Specified by:
readLine
in interfaceDataInput
- Throws:
IOException
-
readLong
public long readLong() throws IOException
- Specified by:
readLong
in interfaceDataInput
- Throws:
IOException
-
readShort
public short readShort() throws IOException
- Specified by:
readShort
in interfaceDataInput
- Throws:
IOException
-
readUTF
public String readUTF() throws IOException
- Specified by:
readUTF
in interfaceDataInput
- Throws:
IOException
-
readUnsignedByte
public int readUnsignedByte() throws IOException
- Specified by:
readUnsignedByte
in interfaceDataInput
- Throws:
IOException
-
readUnsignedShort
public int readUnsignedShort() throws IOException
- Specified by:
readUnsignedShort
in interfaceDataInput
- Throws:
IOException
-
skipBytes
public int skipBytes(int n) throws IOException
- Specified by:
skipBytes
in interfaceDataInput
- Throws:
IOException
-
-