public class OutputBuffer extends FilterOutputStream
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
out
构造器和说明 |
---|
OutputBuffer()
Constructs a new empty buffer.
|
限定符和类型 | 方法和说明 |
---|---|
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.
|
public byte[] getData()
getLength()
.public int getLength()
public OutputBuffer reset()
public void write(InputStream in, int length) throws IOException
IOException
Copyright © 2009 The Apache Software Foundation