Package org.fusesource.hawtbuf
Class BufferOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.fusesource.hawtbuf.BufferOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public final class BufferOutputStream extends java.io.OutputStreamVery 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.
-
-
Constructor Summary
Constructors Constructor Description BufferOutputStream(byte[] buffer)BufferOutputStream(int size)BufferOutputStream(Buffer data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckCapacity(int minimumCapacity)Ensures the the buffer has at least the minimumCapacity specified.BuffergetNextBuffer(int len)voidreset()intsize()BuffertoBuffer()byte[]toByteArray()voidwrite(byte[] b, int off, int len)voidwrite(int b)
-
-
-
Constructor Detail
-
BufferOutputStream
public BufferOutputStream(int size)
-
BufferOutputStream
public BufferOutputStream(byte[] buffer)
-
BufferOutputStream
public BufferOutputStream(Buffer data)
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
getNextBuffer
public Buffer getNextBuffer(int len) throws java.io.IOException
- Throws:
java.io.IOException
-
checkCapacity
private void checkCapacity(int minimumCapacity) throws java.io.IOExceptionEnsures the the buffer has at least the minimumCapacity specified.- Parameters:
i-- Throws:
java.io.EOFExceptionjava.io.IOException
-
reset
public void reset()
-
toBuffer
public Buffer toBuffer()
-
toByteArray
public byte[] toByteArray()
-
size
public int size()
-
-