|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
it.unimi.dsi.mg4j.io.FastByteArrayOutputStream
Simple, fast byte-array output stream that exposes the backing array.
ByteArrayOutputStream
is nice, but to get its content you
must generate each time a new object. This doesn't happen here.
This class will automatically enlarge the backing array, doubling its
size whenever new space is needed. The reset()
method will
mark the content as empty, but will not decrease the capacity: use
trim()
for that purpose.
Field Summary | |
byte[] |
array
The array backing the output stream. |
static int |
DEFAULT_INITIAL_CAPACITY
The array backing the output stream. |
int |
length
The number of valid bytes in array . |
Constructor Summary | |
FastByteArrayOutputStream()
Creates a new array output stream with an initial capacity of DEFAULT_INITIAL_CAPACITY bytes. |
|
FastByteArrayOutputStream(byte[] a)
Creates a new array output stream wrapping a given byte array. |
|
FastByteArrayOutputStream(int initialCapacity)
Creates a new array output stream with a given initial capacity. |
Method Summary | |
void |
reset()
Marks this array output stream as empty. |
void |
trim()
Ensures that the length of the backing array is equal to length . |
void |
write(int b)
|
Methods inherited from class java.io.OutputStream |
close, flush, write, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_INITIAL_CAPACITY
public byte[] array
public int length
array
.
Constructor Detail |
public FastByteArrayOutputStream()
DEFAULT_INITIAL_CAPACITY
bytes.
public FastByteArrayOutputStream(int initialCapacity)
initialCapacity
- the initial length of the backing array.public FastByteArrayOutputStream(byte[] a)
a
- the byte array to wrap.Method Detail |
public void reset()
public void trim()
length
.
public void write(int b)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |