|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
java.io.ByteArrayOutputStream
public class ByteArrayOutputStream
ByteArrayOutputStream is a class whose underlying stream is represented by a byte array. As bytes are written to this stream, the local byte array may be expanded to hold more bytes.
ByteArrayInputStream| Field Summary | |
|---|---|
protected byte[] |
buf
The byte array containing the bytes written. |
protected int |
count
The number of bytes written. |
| Constructor Summary | |
|---|---|
ByteArrayOutputStream()
Constructs a new ByteArrayOutputStream with a default size of 32 bytes. |
|
ByteArrayOutputStream(int size)
Constructs a new ByteArrayOutputStream with a default size of size bytes. |
|
| Method Summary | |
|---|---|
void |
close()
Close this ByteArrayOutputStream. |
void |
reset()
Reset this ByteArrayOutputStream to the beginning of the underlying byte array. |
int |
size()
Answers the total number of bytes written to this stream thus far. |
byte[] |
toByteArray()
Answer the contents of this ByteArrayOutputStream as a byte array. |
String |
toString()
Answer the contents of this ByteArrayOutputStream as a String. |
void |
write(byte[] buffer,
int offset,
int len)
Writes count bytes from the byte array
buffer starting at offset index to the
ByteArrayOutputStream. |
void |
write(int oneByte)
Writes the specified byte oneByte to the OutputStream. |
void |
writeTo(OutputStream out)
Take the contents of this stream and write it to the output stream out. |
| Methods inherited from class java.io.OutputStream |
|---|
flush, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, println |
| Field Detail |
|---|
protected byte[] buf
protected int count
| Constructor Detail |
|---|
public ByteArrayOutputStream()
public ByteArrayOutputStream(int size)
size bytes. If more than size bytes are
written to this instance, the underlying byte array will expand to
accommodate.
size - an non-negative integer representing the initial size for the
underlying byte array.| Method Detail |
|---|
public void close()
throws IOException
close in class OutputStreamIOException - If an error occurs attempting to close this OutputStream.public void reset()
public int size()
public byte[] toByteArray()
public String toString()
toString in class Object
public void write(byte[] buffer,
int offset,
int len)
count bytes from the byte array
buffer starting at offset index to the
ByteArrayOutputStream.
write in class OutputStreambuffer - the buffer to be writtenoffset - offset in buffer to get byteslen - number of bytes in buffer to write
NullPointerException - If buffer is null.
IndexOutOfBoundsException - If offset or count are outside of bounds.public void write(int oneByte)
oneByte to the OutputStream.
Only the low order byte of oneByte is written.
write in class OutputStreamoneByte - the byte to be written
public void writeTo(OutputStream out)
throws IOException
out.
out - An OutputStream on which to write the contents of this stream.
IOException - If an error occurs when writing to output stream
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||