类 ResizableByteArrayOutputStream
java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
cn.taketoday.util.ResizableByteArrayOutputStream
- 所有已实现的接口:
Closeable,Flushable,AutoCloseable
An extension of
ByteArrayOutputStream that:
- has public
grow(int)andresize(int)methods to get more control over the size of the internal buffer - has a higher initial capacity (256) by default
this class has been superseded by FastByteArrayOutputStream
for internal use where no assignability to ByteArrayOutputStream
is needed (since FastByteArrayOutputStream is more efficient with buffer
resize management but doesn't extend the standard ByteArrayOutputStream).
- 从以下版本开始:
- 4.0
- 作者:
- Brian Clozel, Juergen Hoeller, TODAY 2021/8/21 01:19
- 另请参阅:
-
字段概要
字段从类继承的字段 java.io.ByteArrayOutputStream
buf, count -
构造器概要
构造器构造器说明Create a newResizableByteArrayOutputStreamwith the default initial capacity of 256 bytes.ResizableByteArrayOutputStream(int initialCapacity) Create a newResizableByteArrayOutputStreamwith the specified initial capacity. -
方法概要
从类继承的方法 java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, toString, write, write, writeBytes, writeTo从类继承的方法 java.io.OutputStream
flush, nullOutputStream, write
-
字段详细资料
-
DEFAULT_INITIAL_CAPACITY
private static final int DEFAULT_INITIAL_CAPACITY- 另请参阅:
-
-
构造器详细资料
-
ResizableByteArrayOutputStream
public ResizableByteArrayOutputStream()Create a newResizableByteArrayOutputStreamwith the default initial capacity of 256 bytes. -
ResizableByteArrayOutputStream
public ResizableByteArrayOutputStream(int initialCapacity) Create a newResizableByteArrayOutputStreamwith the specified initial capacity.- 参数:
initialCapacity- the initial buffer size in bytes
-
-
方法详细资料
-
resize
public void resize(int targetCapacity) Resize the internal buffer size to a specified capacity.- 参数:
targetCapacity- the desired size of the buffer- 抛出:
IllegalArgumentException- if the given capacity is smaller than the actual size of the content stored in the buffer already- 另请参阅:
-
grow
public void grow(int additionalCapacity) Grow the internal buffer size.- 参数:
additionalCapacity- the number of bytes to add to the current buffer size- 另请参阅:
-
capacity
public int capacity()Return the current size of this stream's internal buffer.
-