March 2002
Intermediate to advanced
480 pages
18h 40m
English
ByteArrayOutputStream
This subclass of OutputStream stores data written to it
in a buffer which can later be retrieved using its
toByteArray() method. When the stream is created, the
buffer is empty. It is then expanded as data is written to the stream.
ByteArrayOutputStream is often used in J2ME in
conjunction with a DataOutputStream to allow strings and
Java primitives types to be stored in a byte array. This byte array is
written to persistent storage on a device using the
RecordStore APIs in the
javax.microedition.rms package.
public class ByteArrayOutputStream extends OutputStream {
// Public Constructors
public ByteArrayOutputStream();
public ByteArrayOutputStream( int size);
// Public Instance Methods
public void reset(); // synchronized
public int size();
public byte[] toByteArray(); // synchronized
// Public Methods Overriding OutputStream
public void close() throws IOException; // synchronized
public void write( int b); // synchronized
public void write( byte[] b, int off, int len); // synchronized
// Public Methods Overriding Object
public String toString();
// Protected Instance Fields
protected byte[] buf;
protected int count;
}
Read now
Unlock full access