|
Build 1.0_r1(from source) | |||||||||
| 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()
Returns 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. |
String |
toString(int hibyte)
Deprecated. Use toString() |
String |
toString(String enc)
Answer the contents of this ByteArrayOutputStream as a String converted using the encoding declared in enc. |
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, 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 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 interface Closeableclose 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@Deprecated public String toString(int hibyte)
toString()
b in this stream is converted to a character
c using the following function:
c == (char)(((hibyte & 0xff) << 8) | (b & 0xff)). This
method is deprecated and either toString(), or toString(String)
should be used.
hibyte - the high byte of each resulting Unicode character
hibyte
public String toString(String enc)
throws UnsupportedEncodingException
enc.
enc - A String representing the encoding to use when translating
this stream to a String.
UnsupportedEncodingException - If declared encoding is not supported
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
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||