Closeable, Flushable, AutoCloseablepublic class MultiByteArrayOutputStream extends OutputStream
toByteArrays() and toString().
Closing a MultiByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
protected List<ByteArrayOutputStream> |
baosList |
The buffer where data is stored.
|
private static int |
BUFFER_INITIALIZED_SIZE |
|
protected long |
count |
The number of valid bytes in the buffer.
|
| 构造器 | 说明 |
|---|---|
MultiByteArrayOutputStream() |
Creates a new byte array output stream.
|
MultiByteArrayOutputStream(int size) |
Creates a new byte array output stream, with a buffer capacity of
the specified size, in bytes.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
close() |
Closing a MultiByteArrayOutputStream has no effect.
|
void |
reset() |
Resets the
count field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. |
long |
size() |
Returns the current size of the buffer.
|
byte[][] |
toByteArrays() |
Creates a newly allocated byte array.
|
void |
write(byte[] b,
int off,
int len) |
Writes
len bytes from the specified byte array
starting at offset off to this byte array output stream. |
void |
write(int b) |
Writes the specified byte to this byte array output stream.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitflush, writeprotected List<ByteArrayOutputStream> baosList
protected long count
private static final int BUFFER_INITIALIZED_SIZE
public MultiByteArrayOutputStream()
public MultiByteArrayOutputStream(int size)
size - the initial size.IllegalArgumentException - if size is negative.public void write(int b)
write 在类中 OutputStreamb - the byte to be written.public void write(byte[] b,
int off,
int len)
len bytes from the specified byte array
starting at offset off to this byte array output stream.write 在类中 OutputStreamb - the data.off - the start offset in the data.len - the number of bytes to write.public void reset()
count field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. The output stream can be used again,
reusing the already allocated buffer space.countpublic byte[][] toByteArrays()
size()public long size()
count field, which is the number
of valid bytes in this output stream.countpublic void close()
throws IOException
close 在接口中 AutoCloseableclose 在接口中 Closeableclose 在类中 OutputStreamIOExceptionCopyright © 2023. All rights reserved.