public class MultiByteArrayOutputStream extends OutputStream implements OutputStreaming
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
m_ab
The current block of output.
|
protected int |
m_cbBlock
The max size of each block.
|
protected int |
m_cBlocks
The number of flushed blocks.
|
protected int |
m_cbPadBack
The number of additional bytes to allocate and leave free at the back
(end) of each block
|
protected int |
m_cbPadFront
The number of additional bytes to allocate and leave free at the front
(start) of each block
|
protected boolean |
m_fClosed
True after close is invoked.
|
protected List |
m_listBlock
The list of blocks.
|
protected int |
m_of
The offset into the current block of output.
|
| Constructor and Description |
|---|
MultiByteArrayOutputStream(int cbBlock)
Construct a MultiByteArrayOutputStream to write to byte arrays of the
specified length.
|
MultiByteArrayOutputStream(int cbBlock,
int cbPadFront,
int cbPadBack)
Construct a MultiByteArrayOutputStream to write to byte arrays of the
specified length, leaving the specified amount of padding at the front
and back of each byte array.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
check()
Verify that the stream is still open.
|
void |
close()
Close the stream, flushing any accumulated bytes.
|
void |
flush()
Flush any accumulated bytes.
|
int |
getBackPaddingSize()
Determine the number of extra bytes of padding that will be allocated
and left blank at the end of each block after the data portion.
|
byte[] |
getBlock(int i)
Obtain the specified block of data.
|
int |
getBlockCount()
Determine the number of blocks that have been written thus far.
|
int |
getBlockDataSize()
Determine the maximum number of bytes of data that will be stored in
each block.
|
int |
getBlockDataSize(int i)
Determine the specific number of bytes of data stored in the specified
block.
|
int |
getFrontPaddingSize()
Determine the number of extra bytes of padding that will be allocated
and left blank at the start of each block in front of the data portion.
|
protected int |
requestCapacity(int cbMore)
Ensure that the current block contains some available capacity, preferably
enough to fulfill the specified capacity.
|
String |
toString()
Create a human readable string representing the data written to the
stream.
|
void |
write(byte[] abSrc,
int ofSrc,
int cbSrc)
Writes
len bytes from the specified byte array
starting at offset off to this output stream. |
void |
write(int b)
Writes the specified byte to this output stream.
|
writeprotected byte[] m_ab
protected int m_of
protected int m_cbBlock
protected int m_cbPadFront
protected int m_cbPadBack
protected List m_listBlock
protected int m_cBlocks
protected boolean m_fClosed
public MultiByteArrayOutputStream(int cbBlock)
cbBlock - the number of bytes (maximum) per blockpublic MultiByteArrayOutputStream(int cbBlock,
int cbPadFront,
int cbPadBack)
cbBlock - the number of data bytes (maximum) per blockcbPadFront - the number of additional bytes to allocate and
leave free at the front (start) of each blockcbPadBack - the number of additional bytes to allocate and
leave free at the back (end) of each blockpublic void write(int b)
throws IOException
write in interface com.oracle.common.io.OutputStreamingwrite in class OutputStreamb - the byte.IOException - if an I/O error occurs. In particular,
an IOException may be thrown if the
output stream has been closed.public void write(byte[] abSrc,
int ofSrc,
int cbSrc)
throws IOException
len bytes from the specified byte array
starting at offset off to this output stream.
If b is null, a
NullPointerException is thrown.
If off is negative, or len is negative, or
off+len is greater than the length of the array
b, then an IndexOutOfBoundsException is thrown.
write in interface com.oracle.common.io.OutputStreamingwrite in class OutputStreamabSrc - the dataofSrc - the start offset in the datacbSrc - the number of bytes to writeIOException - if an I/O error occurs. In particular,
an IOException is thrown if the output
stream is closed.public void flush()
throws IOException
flush in interface com.oracle.common.io.OutputStreamingflush in interface Flushableflush in class OutputStreamIOException - if an I/O error occurspublic void close()
throws IOException
close in interface com.oracle.common.io.OutputStreamingclose in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOException - if an I/O error occurspublic String toString()
public int getBlockCount()
public byte[] getBlock(int i)
i - block index in the range [0..getBlockCount()]; passing the
getBlockCount() will return the active blockpublic int getBlockDataSize(int i)
i - block index in the range [0..getBlockCount()]; passing the
getBlockCount() will return the size of the active blockpublic int getBlockDataSize()
public int getFrontPaddingSize()
public int getBackPaddingSize()
protected void check()
throws IOException
IOExceptionprotected int requestCapacity(int cbMore)
cbMore - the requested capacity