Package org.fusesource.hawtbuf
Class BufferOutputStream
java.lang.Object
java.io.OutputStream
org.fusesource.hawtbuf.BufferOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Very similar to the java.io.ByteArrayOutputStream but this version
is not thread safe and the resulting data is returned in a Buffer
to avoid an extra byte[] allocation. It also does not re-grow it's
internal buffer.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBufferOutputStream
(byte[] buffer) BufferOutputStream
(int size) BufferOutputStream
(Buffer data) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
checkCapacity
(int minimumCapacity) Ensures the the buffer has at least the minimumCapacity specified.getNextBuffer
(int len) void
reset()
int
size()
toBuffer()
byte[]
void
write
(byte[] b, int off, int len) void
write
(int b) Methods inherited from class java.io.OutputStream
close, flush, write
-
Field Details
-
buffer
byte[] buffer -
offset
int offset -
limit
int limit -
pos
int pos
-
-
Constructor Details
-
BufferOutputStream
public BufferOutputStream(int size) -
BufferOutputStream
public BufferOutputStream(byte[] buffer) -
BufferOutputStream
-
-
Method Details
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
getNextBuffer
- Throws:
IOException
-
checkCapacity
Ensures the the buffer has at least the minimumCapacity specified.- Parameters:
i
-- Throws:
EOFException
IOException
-
reset
public void reset() -
toBuffer
-
toByteArray
public byte[] toByteArray() -
size
public int size()
-