<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.io.ByteArrayOutputStream
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.io.html">This Package</a>  <a href="java.io.ByteArrayInputStream.html#_top_">Previous</a>  <a href="java.io.CharArrayReader.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.io.ByteArrayOutputStream
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----<a href="java.io.OutputStream.html#_top_">java.io.OutputStream</a>
           |
           +----java.io.ByteArrayOutputStream
</pre>
<hr>
<dl>
  <dt> public class <b>ByteArrayOutputStream</b>
  <dt> extends <a href="java.io.OutputStream.html#_top_">OutputStream</a>
</dl>
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 <code>toByteArray()</code> and
 <code>toString()</code>.
<p>
<hr>
<a name="index"></a>
<h2>
  <img src="images/variable-index.gif" width=207 height=38 alt="Variable Index">
</h2>
<dl>
  <dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#buf"><b>buf</b></a>
  <dd> 
 The buffer where data is stored.
  <dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#count"><b>count</b></a>
  <dd>  The number of valid bytes in the buffer.
</dl>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#ByteArrayOutputStream()"><b>ByteArrayOutputStream</b></a>()
  <dd>  Creates a new byte array output stream.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#ByteArrayOutputStream(int)"><b>ByteArrayOutputStream</b></a>(int)
  <dd>  Creates a new byte array output stream, with a buffer capacity of 
 the specified size, in bytes.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#reset()"><b>reset</b></a>()
  <dd>  Resets the <code>count</code> field of this byte array output 
 stream to zero, so that all currently accumulated output in the 
 ouput stream is discarded.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#size()"><b>size</b></a>()
  <dd>  Returns the current size of the buffer.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#toByteArray()"><b>toByteArray</b></a>()
  <dd>  Creates a newly allocated byte array.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#toString()"><b>toString</b></a>()
  <dd>  Converts the buffer's contents into a string, translating bytes into
 characters according to the platform's default character encoding.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#toString(int)"><b>toString</b></a>(int)
  <dd>  Creates a newly allocated string.
<b>Deprecated.</b>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#toString(java.lang.String)"><b>toString</b></a>(String)
  <dd>  Converts the buffer's contents into a string, translating bytes into
 characters according to the specified character encoding.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#write(byte[], int, int)"><b>write</b></a>(byte[], int, int)
  <dd>  Writes <code>len</code> bytes from the specified byte array 
 starting at offset <code>off</code> to this byte array output stream.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#write(int)"><b>write</b></a>(int)
  <dd>  Writes the specified byte to this byte array output stream.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#writeTo(java.io.OutputStream)"><b>writeTo</b></a>(OutputStream)
  <dd>  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 <code>out.write(buf, 0, count)</code>.
</dl>
<a name="variables"></a>
<h2>
  <img src="images/variables.gif" width=153 height=38 alt="Variables">
</h2>
<a name="buf"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>buf</b>
<pre>
 protected byte buf[]
</pre>
<dl>
  <dd> The buffer where data is stored.<p>
</dl>
<a name="count"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>count</b>
<pre>
 protected int count
</pre>
<dl>
  <dd> The number of valid bytes in the buffer.<p>
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="ByteArrayOutputStream"></a>
<a name="ByteArrayOutputStream()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>ByteArrayOutputStream</b>
<pre>
 public ByteArrayOutputStream()
</pre>
<dl>
  <dd> Creates a new byte array output stream. The buffer capacity is 
 initially 32 bytes, though its size increases if necessary.
<p>
</dl>
<a name="ByteArrayOutputStream(int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>ByteArrayOutputStream</b>
<pre>
 public ByteArrayOutputStream(int size)
</pre>
<dl>
  <dd> Creates a new byte array output stream, with a buffer capacity of 
 the specified size, in bytes.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> size - the initial size.
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="write(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="write"><b>write</b></a>
<pre>
 public synchronized void write(int b)
</pre>
<dl>
  <dd> Writes the specified byte to this byte array output stream.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> b - the byte to be written.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.io.OutputStream.html#write(int)">write</a> in class <a href="java.io.OutputStream.html#_top_">OutputStream</a>
  </dl></dd>
</dl>
<a name="write(byte[], int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="write"><b>write</b></a>
<pre>
 public synchronized void write(byte b[],
                                int off,
                                int len)
</pre>
<dl>
  <dd> Writes <code>len</code> bytes from the specified byte array 
 starting at offset <code>off</code> to this byte array output stream.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> b - the data.
    <dd> off - the start offset in the data.
    <dd> len - the number of bytes to write.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.io.OutputStream.html#write(byte[], int, int)">write</a> in class <a href="java.io.OutputStream.html#_top_">OutputStream</a>
  </dl></dd>
</dl>
<a name="writeTo(java.io.OutputStream)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="writeTo"><b>writeTo</b></a>
<pre>
 public synchronized void writeTo(<a href="java.io.OutputStream.html#_top_">OutputStream</a> out) throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> 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 <code>out.write(buf, 0, count)</code>.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> out - the output stream to which to write the data.
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if an I/O error occurs.
  </dl></dd>
</dl>
<a name="reset()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="reset"><b>reset</b></a>
<pre>
 public synchronized void reset()
</pre>
<dl>
  <dd> Resets the <code>count</code> 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.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.io.ByteArrayInputStream.html#count">count</a>
  </dl></dd>
</dl>
<a name="toByteArray()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="toByteArray"><b>toByteArray</b></a>
<pre>
 public synchronized byte[] toByteArray()
</pre>
<dl>
  <dd> 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.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the current contents of this output stream, as a byte array.
    <dt> <b>See Also:</b>
    <dd> <a href="#size()">size</a>
  </dl></dd>
</dl>
<a name="size()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="size"><b>size</b></a>
<pre>
 public int size()
</pre>
<dl>
  <dd> Returns the current size of the buffer.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the value of the <code>count</code> field, which is the number
          of valid bytes in this output stream.
    <dt> <b>See Also:</b>
    <dd> <a href="#count">count</a>
  </dl></dd>
</dl>
<a name="toString()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="toString"><b>toString</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> toString()
</pre>
<dl>
  <dd> Converts the buffer's contents into a string, translating bytes into
 characters according to the platform's default character encoding.
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.lang.Object.html#toString()">toString</a> in class <a href="java.lang.Object.html#_top_">Object</a>
  </dl></dd>
</dl>
<a name="toString(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="toString"><b>toString</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> toString(<a href="java.lang.String.html#_top_">String</a> enc) throws <a href="java.io.UnsupportedEncodingException.html#_top_">UnsupportedEncodingException</a>
</pre>
<dl>
  <dd> Converts the buffer's contents into a string, translating bytes into
 characters according to the specified character encoding.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> enc - a character-encoding name.
  </dl></dd>
</dl>
<a name="toString(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="toString"><b>toString</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> toString(int hibyte)
</pre>
<dl>
<dd><b> Note: toString() is deprecated.</b>
<i>This method does not properly convert bytes into characters.
 As of JDK&nbsp;1.1, the preferred way to do this is via the
 <code>toString(String enc)</code> method, which takes an encoding-name
 argument, or the <code>toString()</code> method, which uses the
 platform's default character encoding.</i>
<p>
  <dd> Creates a newly allocated string. Its size is the current size of 
 the output stream and the valid contents of the buffer have been 
 copied into it. Each character <i>c</i> in the resulting string is 
 constructed from the corresponding element <i>b</i> in the byte 
 array such that:
 <ul><code>
     c == (char)(((hibyte &amp; 0xff) &lt;&lt; 8) | (b &amp; 0xff))
 </code></ul>
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> hibyte - the high byte of each resulting Unicode character.
    <dt> <b>Returns:</b>
    <dd> the current contents of the output stream, as a string.
    <dt> <b>See Also:</b>
    <dd> <a href="#size()">size</a>, <a href="#toString(String)">toString</a>, <a href="#toString()">toString</a>
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.io.html">This Package</a>  <a href="java.io.ByteArrayInputStream.html#_top_">Previous</a>  <a href="java.io.CharArrayReader.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
