public final class ByteOutputBuffer
extends java.io.OutputStream
Constructor and Description |
---|
ByteOutputBuffer()
Create a new ByteOutputBuffer with default initial capacity.
|
ByteOutputBuffer(int size)
Create a new ByteOutputBuffer with a specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns the number of bytes available for reading.
|
void |
close()
Prevent further writing to this stream.
|
void |
flush()
In ByteOutputBuffer this is a NOOP.
|
byte[] |
getRemainder()
Returns the remaining elements in the buffer from the
current read pointer position.
|
int |
read()
Return the next element from the buffer.
|
int |
read(byte[] b)
Read from the buffer into the given byte array.
|
int |
read(byte[] b,
int off,
int len)
Read from the buffer into the given byte array at a specified
offset into the byte array with a given length.
|
static byte[] |
readFully(java.io.InputStream is)
Read an InputStream to it's end and return the
resulting byte array.
|
void |
reset()
Reset the ByteOutputBuffer for re-use.
|
void |
resetRead()
Reset the read pointer to the beginning of the buffer.
|
int |
size()
Returns the number of bytes written to the stream since it
was created or since it was last reset().
|
byte[] |
toByteArray()
Returns a byte array representation of the currently accumulated
stream.
|
java.lang.String |
toString()
Return a string representation of stream's contents.
|
java.lang.String |
toString(java.lang.String encoding)
Return a string representation of stream's contents using a
specified String encoding.
|
void |
write(byte[] b)
Write a byte array to the stream.
|
void |
write(byte[] b,
int off,
int len)
Write a portion of a byte array to the stream.
|
void |
write(int b)
Write a single byte to the stream.
|
void |
writeToStream(java.io.OutputStream out)
Write the entire contents of the stream to another OutputStream.
|
public ByteOutputBuffer()
public ByteOutputBuffer(int size)
public static byte[] readFully(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public void reset()
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public int size()
public void writeToStream(java.io.OutputStream out) throws java.io.IOException
java.io.IOException
toByteArray
public byte[] toByteArray()
writeToStream
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String encoding) throws java.lang.Exception
java.lang.Exception
public void resetRead()
public int read()
public int read(byte[] b)
public int read(byte[] b, int off, int len)
public byte[] getRemainder()
public int available()