@InterfaceAudience.Private public class ByteBufferListOutputStream extends ByteBufferOutputStream
releaseResources()
method once the Stream usage is over and
data is transferred to the wanted destination.
Not thread safe!Modifier and Type | Field and Description |
---|---|
protected List<SingleByteBuff> |
allBufs |
private ByteBuffAllocator |
allocator |
private boolean |
lastBufFlipped |
private static org.slf4j.Logger |
LOG |
curBuf
Constructor and Description |
---|
ByteBufferListOutputStream(ByteBuffAllocator allocator) |
Modifier and Type | Method and Description |
---|---|
private void |
allocateNewBuffer() |
protected void |
checkSizeAndGrow(int extra) |
ByteBuffer |
getByteBuffer()
This flips the underlying BB so be sure to use it _last_!
|
List<ByteBuffer> |
getByteBuffers()
We can be assured that the buffers returned by this method are all flipped
|
void |
releaseResources()
Release the resources it uses (The ByteBuffers) which are obtained from pool.
|
int |
size() |
byte[] |
toByteArray(int offset,
int length) |
void |
write(byte[] b,
int off,
int len) |
void |
write(ByteBuffer b,
int off,
int len)
Writes
len bytes from the specified ByteBuffer starting at offset off |
void |
writeTo(OutputStream out)
Writes the complete contents of this byte buffer output stream to
the specified output stream argument.
|
private static final org.slf4j.Logger LOG
private final ByteBuffAllocator allocator
protected List<SingleByteBuff> allBufs
private boolean lastBufFlipped
public ByteBufferListOutputStream(ByteBuffAllocator allocator)
private void allocateNewBuffer()
public int size()
size
in class ByteBufferOutputStream
public ByteBuffer getByteBuffer()
ByteBufferOutputStream
getByteBuffer
in class ByteBufferOutputStream
protected void checkSizeAndGrow(int extra)
checkSizeAndGrow
in class ByteBufferOutputStream
public void writeTo(OutputStream out) throws IOException
ByteBufferOutputStream
writeTo
in class ByteBufferOutputStream
out
- the output stream to which to write the data.IOException
- if an I/O error occurs.public void releaseResources()
public byte[] toByteArray(int offset, int length)
toByteArray
in class ByteBufferOutputStream
public List<ByteBuffer> getByteBuffers()
public void write(byte[] b, int off, int len) throws IOException
write
in class ByteBufferOutputStream
IOException
public void write(ByteBuffer b, int off, int len) throws IOException
ByteBufferWriter
len
bytes from the specified ByteBuffer starting at offset off
write
in interface ByteBufferWriter
write
in class ByteBufferOutputStream
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.IOException
- if an I/O error occurs.Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.