- java.lang.Object
-
- java.io.OutputStream
-
- io.netty5.buffer.BufferOutputStream
-
- All Implemented Interfaces:
Closeable
,DataOutput
,Flushable
,AutoCloseable
public final class BufferOutputStream extends OutputStream implements DataOutput
AnOutputStream
which writes data to aBuffer
.A write operation against this stream will occur at the
writerOffset
of its underlying buffer and thewriterOffset
will increase during the write operation.This stream implements
DataOutput
for your convenience. The endianness of the stream is always big endian.- See Also:
BufferInputStream
-
-
Constructor Summary
Constructors Constructor Description BufferOutputStream(Buffer buffer)
Creates a new stream which writes data to the specifiedbuffer
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Buffer
buffer()
Returns the buffer where this stream is writing data.void
close()
void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int b)
void
writeBoolean(boolean v)
void
writeByte(int v)
void
writeBytes(String s)
void
writeChar(int v)
void
writeChars(String s)
void
writeDouble(double v)
void
writeFloat(float v)
void
writeInt(int v)
void
writeLong(long v)
void
writeShort(int v)
void
writeUTF(String s)
int
writtenBytes()
Returns the number of written bytes by this stream so far.-
Methods inherited from class java.io.OutputStream
flush, nullOutputStream
-
-
-
-
Constructor Detail
-
BufferOutputStream
public BufferOutputStream(Buffer buffer)
Creates a new stream which writes data to the specifiedbuffer
.
-
-
Method Detail
-
writtenBytes
public int writtenBytes()
Returns the number of written bytes by this stream so far.
-
write
public void write(byte[] b, int off, int len) throws IOException
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b) throws IOException
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(int b) throws IOException
- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
writeBoolean
public void writeBoolean(boolean v) throws IOException
- Specified by:
writeBoolean
in interfaceDataOutput
- Throws:
IOException
-
writeByte
public void writeByte(int v) throws IOException
- Specified by:
writeByte
in interfaceDataOutput
- Throws:
IOException
-
writeBytes
public void writeBytes(String s) throws IOException
- Specified by:
writeBytes
in interfaceDataOutput
- Throws:
IOException
-
writeChar
public void writeChar(int v) throws IOException
- Specified by:
writeChar
in interfaceDataOutput
- Throws:
IOException
-
writeChars
public void writeChars(String s) throws IOException
- Specified by:
writeChars
in interfaceDataOutput
- Throws:
IOException
-
writeDouble
public void writeDouble(double v) throws IOException
- Specified by:
writeDouble
in interfaceDataOutput
- Throws:
IOException
-
writeFloat
public void writeFloat(float v) throws IOException
- Specified by:
writeFloat
in interfaceDataOutput
- Throws:
IOException
-
writeInt
public void writeInt(int v) throws IOException
- Specified by:
writeInt
in interfaceDataOutput
- Throws:
IOException
-
writeLong
public void writeLong(long v) throws IOException
- Specified by:
writeLong
in interfaceDataOutput
- Throws:
IOException
-
writeShort
public void writeShort(int v) throws IOException
- Specified by:
writeShort
in interfaceDataOutput
- Throws:
IOException
-
writeUTF
public void writeUTF(String s) throws IOException
- Specified by:
writeUTF
in interfaceDataOutput
- Throws:
IOException
-
buffer
public Buffer buffer()
Returns the buffer where this stream is writing data.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
-