@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 ByteBufferOutputStreampublic ByteBuffer getByteBuffer()
ByteBufferOutputStreamgetByteBuffer in class ByteBufferOutputStreamprotected void checkSizeAndGrow(int extra)
checkSizeAndGrow in class ByteBufferOutputStreampublic void writeTo(OutputStream out) throws IOException
ByteBufferOutputStreamwriteTo in class ByteBufferOutputStreamout - 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 ByteBufferOutputStreampublic List<ByteBuffer> getByteBuffers()
public void write(byte[] b, int off, int len) throws IOException
write in class ByteBufferOutputStreamIOExceptionpublic void write(ByteBuffer b, int off, int len) throws IOException
ByteBufferWriterlen bytes from the specified ByteBuffer starting at offset offwrite in interface ByteBufferWriterwrite in class ByteBufferOutputStreamb - 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.