public class DataOutputBuffer extends DataOutputStream
DataOutput
implementation that writes to an in-memory
buffer.
This saves memory over creating a new DataOutputStream and ByteArrayOutputStream each time data is written.
Typical usage is something like the following:
DataOutputBuffer buffer = new DataOutputBuffer(); while (... loop condition ...) { buffer.reset(); ... write buffer using DataOutput methods ... byte[] data = buffer.getData(); int dataLength = buffer.getLength(); ... write data to its ultimate destination ... }
written
out
构造器和说明 |
---|
DataOutputBuffer()
Constructs a new empty buffer.
|
DataOutputBuffer(int size) |
限定符和类型 | 方法和说明 |
---|---|
byte[] |
getData()
Returns the current contents of the buffer.
|
int |
getLength()
Returns the length of the valid data currently in the buffer.
|
DataOutputBuffer |
reset()
Resets the buffer to empty.
|
void |
write(DataInput in,
int length)
Writes bytes from a DataInput directly into the buffer.
|
void |
writeTo(OutputStream out)
Write to a file stream
|
flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
close, write
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
write
public DataOutputBuffer()
public DataOutputBuffer(int size)
public byte[] getData()
getLength()
.public int getLength()
public DataOutputBuffer reset()
public void write(DataInput in, int length) throws IOException
IOException
public void writeTo(OutputStream out) throws IOException
IOException
Copyright © 2009 The Apache Software Foundation