java::io::ByteArrayOutputStream Class Reference

Inheritance diagram for java::io::ByteArrayOutputStream:

Inheritance graph
java::lang::Objectjava::lang::Interfacejava::io::OutputStream
[legend]
Collaboration diagram for java::io::ByteArrayOutputStream:

Collaboration graph
java::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::io::OutputStreamjava::lang::Comparable
[legend]

List of all members.


Detailed Description

This class implements an output stream in which the data is written into a byte array.

The buffer automatically grows as data is written to it. The data can be retrieved using toByteArray() and toString().

Author:
Arthur van Hoff
Version:
1.43, 02/02/00
Since:
JDK1.0

Public Member Functions

 ByteArrayOutputStream (jint initialSize=32)
 Creates a new byte array output stream.
virtual void write (jint b)
 Writes the specified byte to this byte array output stream.
virtual void write (const Array< jbyte > &b, jint off=0, jint len=-1)
 Writes len bytes from the specified byte array starting at offset off to this byte array output stream.
virtual void reset ()
 Resets the count field of this byte array output stream to zero, so that all currently accumulated output in the ouput stream is discarded.
virtual void close ()
 Closes this output stream and releases any system resources associated with this stream.
virtual void writeTo (OutputStream &out) const
 Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count).
Array< jbytetoByteArray () const
 Creates a newly allocated byte array.
virtual jint size () const
 Returns the current size of the buffer.
String toString () const
 Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.

Constructor & Destructor Documentation

java::io::ByteArrayOutputStream::ByteArrayOutputStream ( jint  initialSize = 32  ) 

Creates a new byte array output stream.

The buffer capacity is initially 32 bytes, though its size increases if necessary.


Member Function Documentation

virtual void java::io::ByteArrayOutputStream::write ( jint  b  )  [virtual]

Writes the specified byte to this byte array output stream.

Parameters:
b the byte to be written.

Implements java::io::OutputStream.

virtual void java::io::ByteArrayOutputStream::write ( const Array< jbyte > &  b,
jint  off = 0,
jint  len = -1 
) [virtual]

Writes len bytes from the specified byte array starting at offset off to this byte array output stream.

Parameters:
b the data.
off the start offset in the data.
len the number of bytes to write.

Implements java::io::OutputStream.

virtual void java::io::ByteArrayOutputStream::reset (  )  [virtual]

Resets the count field of this byte array output stream to zero, so that all currently accumulated output in the ouput stream is discarded.

The output stream can be used again, reusing the already allocated buffer space.

virtual void java::io::ByteArrayOutputStream::close (  )  [virtual]

Closes this output stream and releases any system resources associated with this stream.

A closed stream cannot perform output operations and cannot be reopened.

Reimplemented from java::io::OutputStream.

virtual void java::io::ByteArrayOutputStream::writeTo ( OutputStream out  )  const [virtual]

Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count).

Parameters:
out the output stream to which to write the data.
Exceptions:
IOException if an I/O error occurs.

Array<jbyte> java::io::ByteArrayOutputStream::toByteArray (  )  const

Creates a newly allocated byte array.

Its size is the current size of this output stream and the valid contents of the buffer have been copied into it. No thread protection for efficiency. Use with care.

Returns:
the current contents of this output stream, as a byte array.
See also:
java.io.ByteArrayOutputStream::size()

virtual jint java::io::ByteArrayOutputStream::size (  )  const [virtual]

Returns the current size of the buffer.

Returns:
the value of the count field, which is the number of valid bytes in this output stream.

String java::io::ByteArrayOutputStream::toString (  )  const [virtual]

Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.

Returns:
String translated from the buffer's contents.
Since:
JDK1.1

Reimplemented from java::lang::Object.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:27 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3