|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream java.io.FilterOutputStream org.apache.hadoop.io.OutputBuffer
public class OutputBuffer
A reusable OutputStream
implementation that writes to an in-memory
buffer.
This saves memory over creating a new OutputStream and ByteArrayOutputStream each time data is written.
Typical usage is something like the following:
OutputBuffer buffer = new OutputBuffer(); while (... loop condition ...) { buffer.reset(); ... write buffer using OutputStream methods ... byte[] data = buffer.getData(); int dataLength = buffer.getLength(); ... write data to its ultimate destination ... }
DataOutputBuffer
,
InputBuffer
Field Summary |
---|
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
OutputBuffer()
Constructs a new empty buffer. |
Method Summary | |
---|---|
byte[] |
getData()
Returns the current contents of the buffer. |
int |
getLength()
Returns the length of the valid data currently in the buffer. |
OutputBuffer |
reset()
Resets the buffer to empty. |
void |
write(InputStream in,
int length)
Writes bytes from a InputStream directly into the buffer. |
Methods inherited from class java.io.FilterOutputStream |
---|
close, flush, write, write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OutputBuffer()
Method Detail |
---|
public byte[] getData()
getLength()
.
public int getLength()
public OutputBuffer reset()
public void write(InputStream in, int length) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |