Closeable
, Flushable
, AutoCloseable
public final class FastByteArrayOutputStream extends ByteArrayOutputStream
ByteArrayOutputStream
implementation. This version
also has a constructor that lets you create a stream with initial content.
Modifier and Type | Field | Description |
---|---|---|
protected int |
maxGrowSize |
Max grow size (unless if writing more than this amount of bytes)
|
buf, count
Constructor | Description |
---|---|
FastByteArrayOutputStream(byte[] pBuffer) |
Creates a
ByteArrayOutputStream with the given initial content. |
FastByteArrayOutputStream(int pSize) |
Creates a
ByteArrayOutputStream with the given initial buffer
size. |
Modifier and Type | Method | Description |
---|---|---|
ByteArrayInputStream |
createInputStream() |
Creates a
ByteArrayInputStream that reads directly from this
FastByteArrayOutputStream 's byte buffer. |
byte[] |
toByteArray() |
|
void |
write(byte[] pBytes,
int pOffset,
int pLength) |
|
void |
write(int pByte) |
|
void |
writeTo(OutputStream pOut) |
close, reset, size, toString, toString, toString, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
flush, write
protected int maxGrowSize
public FastByteArrayOutputStream(int pSize)
ByteArrayOutputStream
with the given initial buffer
size.pSize
- initial buffer sizepublic FastByteArrayOutputStream(byte[] pBuffer)
ByteArrayOutputStream
with the given initial content.
Note that the buffer is not cloned, for maximum performance.pBuffer
- initial bufferpublic void write(byte[] pBytes, int pOffset, int pLength)
write
in class ByteArrayOutputStream
public void write(int pByte)
write
in class ByteArrayOutputStream
public void writeTo(OutputStream pOut) throws IOException
writeTo
in class ByteArrayOutputStream
IOException
public byte[] toByteArray()
toByteArray
in class ByteArrayOutputStream
public ByteArrayInputStream createInputStream()
ByteArrayInputStream
that reads directly from this
FastByteArrayOutputStream
's byte buffer.
The buffer is not cloned, for maximum performance.
Note that care needs to be taken to avoid writes to
this output stream after the input stream is created.
Failing to do so, may result in unpredictable behaviour.ByteArrayInputStream
, reading from this stream's buffer.Copyright © 2018. All rights reserved.