@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<ByteBuffer> |
allBufs |
protected List<ByteBuffer> |
bufsFromPool |
private boolean |
lastBufFlipped |
private static org.slf4j.Logger |
LOG |
private ByteBufferPool |
pool |
curBuf
Constructor and Description |
---|
ByteBufferListOutputStream(ByteBufferPool pool) |
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 ByteBufferPool pool
protected List<ByteBuffer> allBufs
protected List<ByteBuffer> bufsFromPool
private boolean lastBufFlipped
public ByteBufferListOutputStream(ByteBufferPool pool)
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.