voldemort.common.nio
Class ByteBufferBackedOutputStream
java.lang.Object
java.io.OutputStream
voldemort.common.nio.ByteBufferBackedOutputStream
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable
public class ByteBufferBackedOutputStream
- extends java.io.OutputStream
ByteBufferBackedOutputStream serves two purposes:
- It allows a ByteBuffer to be the source of data for OutputStream-based
callers
- It expands the underlying buffer to accommodate incoming data
This class is used to interface with callers using "classic" java.io.* APIs.
This OutputStream provides the means to grow the buffer on demand as more
data is written by those callers. For code that manages the
ByteBufferBackedOutputStream, there are accessor methods for the underlying
buffer as the object reference passed into the constructor is changed upon
expansion. Additionally, some callers might wish to "un-expand" the buffer
back to a more reasonable size after use.
Methods inherited from class java.io.OutputStream |
flush, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ByteBufferBackedOutputStream
public ByteBufferBackedOutputStream(java.nio.ByteBuffer buffer)
ByteBufferBackedOutputStream
public ByteBufferBackedOutputStream(java.nio.ByteBuffer buffer,
org.apache.commons.lang.mutable.MutableLong sizeTracker)
getBuffer
public java.nio.ByteBuffer getBuffer()
setBuffer
public void setBuffer(java.nio.ByteBuffer newBuffer)
write
public void write(int b)
throws java.io.IOException
- Specified by:
write
in class java.io.OutputStream
- Throws:
java.io.IOException
write
public void write(byte[] bytes,
int off,
int len)
throws java.io.IOException
- Overrides:
write
in class java.io.OutputStream
- Throws:
java.io.IOException
wasExpanded
public boolean wasExpanded()
close
public void close()
- Specified by:
close
in interface java.io.Closeable
- Overrides:
close
in class java.io.OutputStream
Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu