|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--nl.justobjects.toolkit.collection.ByteBuffer
Simple implementation of extensible byte array.
Purpose
Implementation
Examples
$Source: /var/cvs/justobjects/toolkit/src/nl/justobjects/toolkit/collection/ByteBuffer.java,v $
Field Summary | |
protected byte[] |
buf
The buffer where data is stored. |
protected int |
count
The number of valid bytes in the buffer. |
Constructor Summary | |
ByteBuffer()
Creates a new byte buffer. |
|
ByteBuffer(int size)
Creates a new byte buffer, with a buffer capacity of the specified size, in bytes. |
Method Summary | |
void |
add(byte b)
Add the specified byte to this byte buffer. |
void |
add(byte[] b)
Adds bytes from the specified byte array |
void |
add(byte[] b,
int off,
int len)
Adds len bytes from the specified byte array
starting at offset off to this byte buffer. |
void |
add(char c)
|
void |
add(java.lang.String s)
|
void |
reset()
Resets the count field of this byte buffer
to zero |
int |
size()
Returns the current size of the buffer. |
byte[] |
toByteArray()
Creates a newly allocated byte array. |
java.lang.String |
toString()
Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected byte[] buf
protected int count
Constructor Detail |
public ByteBuffer()
public ByteBuffer(int size)
size
- the initial size.java.lang.IllegalArgumentException
- if size is negative.Method Detail |
public void add(byte b)
b
- the byte to be written.public void add(byte[] b)
b
- the data.public void add(byte[] b, int off, int len)
len
bytes from the specified byte array
starting at offset off
to this byte buffer.b
- the data.off
- the start offset in the data.len
- the number of bytes to write.public void add(char c)
public void add(java.lang.String s)
public void reset()
count
field of this byte buffer
to zeropublic byte[] toByteArray()
ByteArrayOutputStream.size()
public int size()
count
field, which is the number
of valid bytes in this buffer.ByteArrayOutputStream.count
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |