public static final class ByteString.Output
extends java.io.OutputStream
Modifier and Type | Field and Description |
---|---|
private byte[] |
buffer |
private int |
bufferPos |
private static byte[] |
EMPTY_BYTE_ARRAY |
private java.util.ArrayList<ByteString> |
flushedBuffers |
private int |
flushedBuffersTotalBytes |
private int |
initialCapacity |
Constructor and Description |
---|
Output(int initialCapacity)
Creates a new ByteString output stream with the specified
initial capacity.
|
Modifier and Type | Method and Description |
---|---|
private byte[] |
copyArray(byte[] buffer,
int length)
Implement java.util.Arrays.copyOf() for jdk 1.5.
|
private void |
flushFullBuffer(int minSize)
Internal function used by writers.
|
private void |
flushLastBuffer()
Internal function used by
toByteString() . |
void |
reset()
Resets this stream, so that all currently accumulated output in the
output stream is discarded.
|
int |
size()
Returns the current size of the output stream.
|
ByteString |
toByteString()
Creates a byte string.
|
java.lang.String |
toString() |
void |
write(byte[] b,
int offset,
int length) |
void |
write(int b) |
void |
writeTo(java.io.OutputStream out)
Writes the complete contents of this byte array output stream to
the specified output stream argument.
|
private static final byte[] EMPTY_BYTE_ARRAY
private final int initialCapacity
private final java.util.ArrayList<ByteString> flushedBuffers
private int flushedBuffersTotalBytes
private byte[] buffer
private int bufferPos
Output(int initialCapacity)
initialCapacity
- the initial capacity of the output stream.public void write(int b)
write
in class java.io.OutputStream
public void write(byte[] b, int offset, int length)
write
in class java.io.OutputStream
public ByteString toByteString()
private byte[] copyArray(byte[] buffer, int length)
public void writeTo(java.io.OutputStream out) throws java.io.IOException
out
- the output stream to which to write the data.java.io.IOException
- if an I/O error occurs.public int size()
public void reset()
public java.lang.String toString()
toString
in class java.lang.Object
private void flushFullBuffer(int minSize)
private void flushLastBuffer()
toByteString()
. The current buffer may
or may not be full, but it needs to be flushed.