public class FastByteArrayOutputStream extends OutputStream
| Constructor and Description |
|---|
FastByteArrayOutputStream(int initialSize,
int bumpSize)
Creates an output stream with a given bump size and initial size.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSize(int sizeAdded)
Skip the given number of bytes in the buffer.
|
byte[] |
getBufferBytes()
Returns the buffer owned by this object.
|
int |
getBufferLength()
Returns the length used in the internal buffer, that is, the offset at
which data will be written next.
|
int |
getBufferOffset()
Returns the offset of the internal buffer.
|
void |
makeSpace(int sizeNeeded)
Ensure that at least the given number of bytes are available in the
internal buffer.
|
void |
reset()
Resets this FastByteArrayOutputStream.
|
int |
size()
Returns the number of bytes written to this
FastByteArrayOutputStream.
|
byte[] |
toByteArray()
Returns the written bytes in a newly allocated byte[]
of length getSize().
|
void |
toByteArray(byte[] toBuf,
int offset)
Copy the buffered data to the given array.
|
String |
toString() |
String |
toString(String encoding)
Returns the content of this FastByteArrayOutputStream
as String.
|
void |
write(byte[] fromBuf) |
void |
write(byte[] fromBuf,
int offset,
int length) |
void |
write(int b) |
void |
writeTo(OutputStream out)
Writes the content of this FastByteArrayOutputStream
to the given output stream.
|
close, flushpublic FastByteArrayOutputStream(int initialSize,
int bumpSize)
initialSize - the initial size of the buffer.bumpSize - the amount to increment the buffer.public int size()
public void reset()
public void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] fromBuf)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] fromBuf,
int offset,
int length)
throws IOException
write in class OutputStreamIOExceptionpublic void writeTo(OutputStream out) throws IOException
out - the output stream to be written to.IOException - if an I/O error occurs.public String toString(String encoding) throws UnsupportedEncodingException
encoding - the encoding to be used for conversion.UnsupportedEncodingException - if the given encoding is not supported.public byte[] toByteArray()
public void toByteArray(byte[] toBuf,
int offset)
toBuf - the buffer to hold a copy of the data.offset - the offset at which to start copying.public byte[] getBufferBytes()
public int getBufferOffset()
public int getBufferLength()
public void makeSpace(int sizeNeeded)
sizeNeeded - the number of bytes desired.public void addSize(int sizeAdded)
sizeAdded - number of bytes to skip.Copyright © 2025. All Rights Reserved.