Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 114
نمايش فراداده

This class is a subclass of OutputStream in which output data is stored in an internal byte array. The internal array grows as necessary and can be retrieved with toByteArray( ) or toString( ). The reset( ) method discards any data currently stored in the internal array and stores data from the beginning again. See also CharArrayWriter.

Figure 9-6. java.io.ByteArrayOutputStream

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

1.1 public String

toString (String

enc ) throws UnsupportedEncodingException; public void

writeTo (OutputStream

out ) throws IOException; synchronized // Public Methods Overriding OutputStream

1.2 public void

close ( ) throws IOException; empty 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 ; // Deprecated Public Methods

# public String

toString (int

hibyte ); }