public class OutputStreamSliceOutput extends SliceOutput
Constructor and Description |
---|
OutputStreamSliceOutput(OutputStream outputStream) |
Modifier and Type | Method and Description |
---|---|
SliceOutput |
appendByte(int value) |
SliceOutput |
appendBytes(byte[] source) |
SliceOutput |
appendBytes(byte[] source,
int sourceIndex,
int length) |
SliceOutput |
appendBytes(Slice slice) |
SliceOutput |
appendDouble(double value) |
SliceOutput |
appendInt(int value) |
SliceOutput |
appendLong(long value) |
SliceOutput |
appendShort(int value) |
void |
close() |
void |
flush() |
int |
getRetainedSize()
Note: This does not include the size of the nested OutputStream.
|
Slice |
getUnderlyingSlice()
Returns the raw underlying slice of this output stream.
|
boolean |
isWritable()
Returns
true
if and only if (this.capacity - this.writerIndex) is greater
than 0 . |
void |
reset()
Resets this stream to the initial position.
|
int |
size()
Returns the
writerIndex of this buffer. |
Slice |
slice()
Returns a slice of this buffer's readable bytes.
|
String |
toString() |
String |
toString(Charset charset)
Decodes this buffer's readable bytes into a string with the specified
character set name.
|
int |
writableBytes()
Returns the number of writable bytes which is equal to
(this.capacity - this.writerIndex) . |
void |
writeByte(int value)
Sets the specified byte at the current
writerIndex
and increases the writerIndex by 1 in this buffer. |
void |
writeBytes(byte[] source)
Transfers the specified source array's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= source.length ). |
void |
writeBytes(byte[] source,
int sourceIndex,
int length)
Transfers the specified source array's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length ). |
void |
writeBytes(InputStream in,
int length)
Transfers the content of the specified stream to this buffer
starting at the current
writerIndex and increases the
writerIndex by the number of the transferred bytes. |
void |
writeBytes(Slice source)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex until the source buffer becomes
unreadable, and increases the writerIndex by the number of
the transferred bytes. |
void |
writeBytes(Slice source,
int sourceIndex,
int length)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length ). |
void |
writeDouble(double value)
Sets the specified 64-bit double at the current
writerIndex and increases the writerIndex by 8
in this buffer. |
void |
writeFloat(float value)
Sets the specified 32-bit float at the current
writerIndex and increases the writerIndex by 4
in this buffer. |
void |
writeInt(int value)
Sets the specified 32-bit integer at the current
writerIndex
and increases the writerIndex by 4 in this buffer. |
void |
writeLong(long value)
Sets the specified 64-bit long integer at the current
writerIndex and increases the writerIndex by 8
in this buffer. |
void |
writeShort(int value)
Sets the specified 16-bit short integer at the current
writerIndex and increases the writerIndex by 2
in this buffer. |
write, write, write, writeBoolean, writeBytes, writeChar, writeChars, writeUTF, writeZero
public OutputStreamSliceOutput(OutputStream outputStream)
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public void reset()
SliceOutput
reset
in class SliceOutput
public int size()
SliceOutput
writerIndex
of this buffer.size
in class SliceOutput
public int getRetainedSize()
getRetainedSize
in class SliceOutput
public int writableBytes()
SliceOutput
(this.capacity - this.writerIndex)
.writableBytes
in class SliceOutput
public boolean isWritable()
SliceOutput
true
if and only if (this.capacity - this.writerIndex)
is greater
than 0
.isWritable
in class SliceOutput
public void writeByte(int value)
SliceOutput
writerIndex
and increases the writerIndex
by 1
in this buffer.
The 24 high-order bits of the specified value are ignored.writeByte
in interface DataOutput
writeByte
in class SliceOutput
public void writeShort(int value)
SliceOutput
writerIndex
and increases the writerIndex
by 2
in this buffer. The 16 high-order bits of the specified value are ignored.writeShort
in interface DataOutput
writeShort
in class SliceOutput
public void writeInt(int value)
SliceOutput
writerIndex
and increases the writerIndex
by 4
in this buffer.writeInt
in interface DataOutput
writeInt
in class SliceOutput
public void writeLong(long value)
SliceOutput
writerIndex
and increases the writerIndex
by 8
in this buffer.writeLong
in interface DataOutput
writeLong
in class SliceOutput
public void writeFloat(float value)
SliceOutput
writerIndex
and increases the writerIndex
by 4
in this buffer.writeFloat
in interface DataOutput
writeFloat
in class SliceOutput
public void writeDouble(double value)
SliceOutput
writerIndex
and increases the writerIndex
by 8
in this buffer.writeDouble
in interface DataOutput
writeDouble
in class SliceOutput
public void writeBytes(Slice source)
SliceOutput
writerIndex
until the source buffer becomes
unreadable, and increases the writerIndex
by the number of
the transferred bytes. This method is basically same with
SliceOutput.writeBytes(Slice, int, int)
, except that this method
increases the readerIndex
of the source buffer by the number of
the transferred bytes while SliceOutput.writeBytes(Slice, int, int)
does not.writeBytes
in class SliceOutput
public void writeBytes(Slice source, int sourceIndex, int length)
SliceOutput
writerIndex
and increases the writerIndex
by the number of the transferred bytes (= length
).writeBytes
in class SliceOutput
sourceIndex
- the first index of the sourcelength
- the number of bytes to transferpublic void writeBytes(byte[] source)
SliceOutput
writerIndex
and increases the writerIndex
by the number of the transferred bytes (= source.length
).writeBytes
in class SliceOutput
public void writeBytes(byte[] source, int sourceIndex, int length)
SliceOutput
writerIndex
and increases the writerIndex
by the number of the transferred bytes (= length
).writeBytes
in class SliceOutput
sourceIndex
- the first index of the sourcelength
- the number of bytes to transferpublic void writeBytes(InputStream in, int length) throws IOException
SliceOutput
writerIndex
and increases the
writerIndex
by the number of the transferred bytes.writeBytes
in class SliceOutput
length
- the number of bytes to transferIOException
- if the specified stream threw an exception during I/Opublic SliceOutput appendLong(long value)
appendLong
in class SliceOutput
public SliceOutput appendDouble(double value)
appendDouble
in class SliceOutput
public SliceOutput appendInt(int value)
appendInt
in class SliceOutput
public SliceOutput appendShort(int value)
appendShort
in class SliceOutput
public SliceOutput appendByte(int value)
appendByte
in class SliceOutput
public SliceOutput appendBytes(byte[] source, int sourceIndex, int length)
appendBytes
in class SliceOutput
public SliceOutput appendBytes(byte[] source)
appendBytes
in class SliceOutput
public SliceOutput appendBytes(Slice slice)
appendBytes
in class SliceOutput
public Slice slice()
SliceOutput
buf.slice(buf.readerIndex(), buf.readableBytes())
.
This method does not modify readerIndex
or writerIndex
of
this buffer.slice
in class SliceOutput
public Slice getUnderlyingSlice()
SliceOutput
getUnderlyingSlice
in class SliceOutput
public String toString(Charset charset)
SliceOutput
buf.toString(buf.readerIndex(), buf.readableBytes(), charsetName)
.
This method does not modify readerIndex
or writerIndex
of
this buffer.toString
in class SliceOutput
Copyright © 2012-2016. All Rights Reserved.