ArrayOutputStream

An output stream that writes to an internal array. The resulting array can be obtained with toArray(). It is BetterC compatible, using manual memory management.

When constructed, an initial block of memory is allocated, and then any new memory will be allocated according to the output stream's allocation strategy. If the None strategy is used, attempts to write more elements than the array contains will throw an unrecoverable Error.

Members

Functions

reset
void reset()

Resets the internal array, such that toArray() returns an empty array.

toArray
E[] toArray()

Gets the internal array to which elements have been appended. This method is not compatible with BetterC mode; use toArrayRaw for that.

toArrayRaw
E[] toArrayRaw()

Gets a slice representing the underlying array to which elements have been appended. Take caution, as this memory segment may be freed if this stream is deconstructed or written to again.

writeToStream
StreamResult writeToStream(E[] buffer)

Writes data to this output stream's internal array.

Meta