Package io.netty.buffer
Class ByteBufOutputStream
java.lang.Object
java.io.OutputStream
io.netty.buffer.ByteBufOutputStream
- All Implemented Interfaces:
Closeable
,DataOutput
,Flushable
,AutoCloseable
An
OutputStream
which writes data to a ByteBuf
.
A write operation against this stream will occur at the writerIndex
of its underlying buffer and the writerIndex
will increase during
the write operation.
This stream implements DataOutput
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 ByteBuf
private boolean
private final int
private DataOutputStream
-
Constructor Summary
ConstructorsConstructorDescriptionByteBufOutputStream
(ByteBuf buffer) Creates a new stream which writes data to the specifiedbuffer
. -
Method Summary
Modifier and TypeMethodDescriptionbuffer()
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
int
Returns the number of written bytes by this stream so far.Methods inherited from class java.io.OutputStream
flush, nullOutputStream
-
Field Details
-
buffer
-
startIndex
private final int startIndex -
utf8out
-
closed
private boolean closed
-
-
Constructor Details
-
ByteBufOutputStream
Creates a new stream which writes data to the specifiedbuffer
.
-
-
Method Details
-
writtenBytes
public int writtenBytes()Returns the number of written bytes by this stream so far. -
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
writeBoolean
- Specified by:
writeBoolean
in interfaceDataOutput
- Throws:
IOException
-
writeByte
- Specified by:
writeByte
in interfaceDataOutput
- Throws:
IOException
-
writeBytes
- Specified by:
writeBytes
in interfaceDataOutput
- Throws:
IOException
-
writeChar
- Specified by:
writeChar
in interfaceDataOutput
- Throws:
IOException
-
writeChars
- Specified by:
writeChars
in interfaceDataOutput
- Throws:
IOException
-
writeDouble
- Specified by:
writeDouble
in interfaceDataOutput
- Throws:
IOException
-
writeFloat
- Specified by:
writeFloat
in interfaceDataOutput
- Throws:
IOException
-
writeInt
- Specified by:
writeInt
in interfaceDataOutput
- Throws:
IOException
-
writeLong
- Specified by:
writeLong
in interfaceDataOutput
- Throws:
IOException
-
writeShort
- Specified by:
writeShort
in interfaceDataOutput
- Throws:
IOException
-
writeUTF
- Specified by:
writeUTF
in interfaceDataOutput
- Throws:
IOException
-
buffer
Returns the buffer where this stream is writing data. -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-