| java.lang.Object net.matuschek.util.ByteBuffer
ByteBuffer | public class ByteBuffer (Code) | | A ByteBuffer implements a growable byte array. You can simple
add bytes like you do it using a Vector, but internally the buffer
is implemented as a real array of bytes. This increases memory usage.
author: Daniel Matuschek version: $Id $ |
Constructor Summary | |
public | ByteBuffer() Initializes a new ByteBuffer object and creates
a temporary buffer array of a predefined initial size. |
Method Summary | |
public void | append(byte b) Appends a byte to the end of the buffer
If the currently reserved memory is used, the size of the
internal buffer will be doubled. | public void | clean() | protected void | doubleBuffer() | public byte[] | getContent() | public int | length() | public void | setSize(int size) Sets the size of the internal buffer to
the given value. | public String | toString() |
INITIALSIZE | final protected int INITIALSIZE(Code) | | |
buff | protected byte[] buff(Code) | | |
ByteBuffer | public ByteBuffer()(Code) | | Initializes a new ByteBuffer object and creates
a temporary buffer array of a predefined initial size.
If you want to set your own initial size, use the setSize
method after initializing the object.
|
append | public void append(byte b)(Code) | | Appends a byte to the end of the buffer
If the currently reserved memory is used, the size of the
internal buffer will be doubled.
In this case the memory usage will temprary increase by factor 3
because it need a temporary storage for the old data.
Be sure that you have enough heap memory !
Parameters: b - byte to append |
clean | public void clean()(Code) | | removes all contents in the buffer
|
doubleBuffer | protected void doubleBuffer()(Code) | | doubles the size of the internal buffer
|
getContent | public byte[] getContent()(Code) | | the buffer contents as a byte array |
length | public int length()(Code) | | the number of bytes stored in the buffer |
setSize | public void setSize(int size)(Code) | | Sets the size of the internal buffer to
the given value. This is useful, if the size of the
data that should be stored is known.
Parameters: size - size of the buffer in Bytes |
toString | public String toString()(Code) | | Print the buffer content as a String (use it for debugging only !)
a String containing every byte in the buffer as a character |
|
|