Package org.aksw.iguana.commons.io
Class ByteArrayListOutputStream
java.lang.Object
java.io.OutputStream
org.aksw.iguana.commons.io.ReversibleOutputStream
org.aksw.iguana.commons.io.ByteArrayListOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
An OutputStream that writes to a list of byte arrays.
The buffers have a minimum size.
If a write operation is smaller than the minimum size, the data is stored in a separate buffer.
This buffer will be filled up by subsequent writings to the minimum size before another buffer is created.
-
Constructor Summary
ConstructorDescriptionCreates a new ByteArrayListOutputStream with a minimum buffer size of 4096 bytes.ByteArrayListOutputStream
(int minBufferSize) Creates a new ByteArrayListOutputStream with the given minimum buffer size. -
Method Summary
Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Constructor Details
-
ByteArrayListOutputStream
public ByteArrayListOutputStream()Creates a new ByteArrayListOutputStream with a minimum buffer size of 4096 bytes. -
ByteArrayListOutputStream
public ByteArrayListOutputStream(int minBufferSize) Creates a new ByteArrayListOutputStream with the given minimum buffer size.- Parameters:
minBufferSize
- the minimum buffer size
-
-
Method Details
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
size
public long size()- Specified by:
size
in classReversibleOutputStream
-
getBuffers
Returns the list of buffers. The list does not contain the current buffer. If the stream is closed, the current buffer is trimmed to the actual size and then added to the list.- Returns:
- the list of buffers
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
toInputStream
- Specified by:
toInputStream
in classReversibleOutputStream
-