Package sonia.scm.io
Class FastByteArrayOutputStream
java.lang.Object
java.io.OutputStream
sonia.scm.io.FastByteArrayOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
ByteArrayOutputStream implementation that doesn't synchronize methods
and doesn't copy the data on toByteArray().
- Since:
- 1.29
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a stream with buffer capacity size 5KFastByteArrayOutputStream
(int initSize) Constructs a stream with the given initial size -
Method Summary
Methods inherited from class java.io.OutputStream
close, flush, nullOutputStream
-
Constructor Details
-
FastByteArrayOutputStream
public FastByteArrayOutputStream()Constructs a stream with buffer capacity size 5K -
FastByteArrayOutputStream
public FastByteArrayOutputStream(int initSize) Constructs a stream with the given initial size- Parameters:
initSize
-
-
-
Method Details
-
write
public final void write(byte[] b) - Overrides:
write
in classOutputStream
-
write
public final void write(byte[] b, int off, int len) - Overrides:
write
in classOutputStream
-
write
public final void write(int b) - Specified by:
write
in classOutputStream
-
reset
public void reset() -
getByteArray
public byte[] getByteArray()Returns the byte array containing the written data. Note that this array will almost always be larger than the amount of data actually written.- Returns:
-
getInputStream
Returns a ByteArrayInputStream for reading back the written data- Returns:
-
getSize
public int getSize()
-