|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.io.OutputStream
|
+--java.io.ByteArrayOutputStream
This class implements a buffer that can be used as an OutputStream. The buffer automatically grows when data is written to the stream. The data can be retrieved using toByteArray() and toString().
| Field Summary | |
protected byte[] |
buf
The buffer where data is stored. |
protected int |
count
The number of bytes in the buffer. |
| Constructor Summary | |
ByteArrayOutputStream()
Creates a new ByteArrayOutputStream. |
|
ByteArrayOutputStream(int size)
Creates a new ByteArrayOutputStream with the specified initial size. |
|
| Method Summary | |
void |
reset()
Resets the buffer so that you can use it again without throwing away the already allocated buffer. |
int |
size()
Returns the current size of the buffer. |
byte[] |
toByteArray()
Returns a copy of the input data. |
String |
toString()
Converts input data to a string. |
String |
toString(int hibyte)
Converts input data to a string. |
void |
write(byte[] b,
int off,
int len)
Writes bytes to the buffer. |
void |
write(int b)
Writes a byte to the buffer. |
void |
writeTo(OutputStream out)
Writes the contents of the buffer to another stream. |
| Methods inherited from class java.io.OutputStream |
close, flush, write |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected byte[] buf
protected int count
| Constructor Detail |
public ByteArrayOutputStream()
public ByteArrayOutputStream(int size)
size - the initial size| Method Detail |
public void write(int b)
write in class OutputStreamb - the byte
public void write(byte[] b,
int off,
int len)
write in class OutputStreamb - the data to be writtenoff - the start offset in the datalen - the number of bytes that are written
public void writeTo(OutputStream out)
throws IOException
out - the output stream to write to
IOExceptionpublic void reset()
public byte[] toByteArray()
public int size()
public String toString()
toString in class Objectpublic String toString(int hibyte)
hibyte - the bits set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||