    All Packages    This Package    Previous    Next

# Class java.io.OutputStreamBuffer

    java.lang.Object
       |
       +----java.io.OutputStream
               |
               +----java.io.OutputStreamBuffer

public class OutputStreamBuffer
extends OutputStream

This class implements a buffer that can be used as an OutputStream. The buffer automatically grows when data is written to the stream. The data can be retrieved using toByteArray() and toString().

Version:
  1.12, 31 Jan 1995
Author:
  Arthur van Hoff

##

buf
  The buffer
count
  The number of bytes in the buffer

##

OutputStreamBuffer()
  Create a new OutputStreamBuffer
OutputStreamBuffer(int)
  Creates a new OutputStreamBuffer, given an initial size.

##

reset()
  Resets the buffer so that you can use it again without throwing away the already allocated buffer.
size()
  Returns the current size of the buffer.
toByteArray()
  Returns a copy of the input data.
toString()
  Converts input data to a string.
toString(int)
  Converts input data to a string.
write(int)
  Writes a byte to the buffer.
write(byte[], int, int)
  Writes bytes to the buffer.
writeTo(OutputStream)
  Writes the contents of the buffer to another stream.

##

buf

      protected byte buf[]

  The buffer

count

      protected int count

  The number of bytes in the buffer

##

OutputStreamBuffer

      public OutputStreamBuffer()

  Create a new OutputStreamBuffer

OutputStreamBuffer

      public OutputStreamBuffer(int size)

  Creates a new OutputStreamBuffer, given an initial size.
  Parameters:
    size - initial size

##

write

      public synchronized void write(int b)

  Writes a byte to the buffer.
  Parameters:
    b - the byte
  Overrides:
    write in class OutputStream

write

      public synchronized void write(byte b[],
                                     int off,
                                     int len)

  Writes bytes to the buffer.
  Parameters:
    b - the data to be written
    off - the start offset in the data
    len - the number of bytes that are written
  Overrides:
    write in class OutputStream

writeTo

      public synchronized void writeTo(OutputStream out)

  Writes the contents of the buffer to another stream.
  Parameters:
    out - the output stream to write to

reset

      public synchronized void reset()

  Resets the buffer so that you can use it again without throwing away the already allocated buffer.

toByteArray

      public synchronized byte toByteArray()

  Returns a copy of the input data.
  Returns:
    a copy of the the buffered data

size

      public int size()

  Returns the current size of the buffer.
  Returns:
    the number of bytes in the buffer

toString

      public String toString()

  Converts input data to a string.
  Returns:
    the string
  Overrides:
    toString in class Object

toString

      public String toString(int hibyte)

  Converts input data to a string. The top 8 bits of each 16 bit UNICODE character are set to hibyte.
  Returns:
    the string

    All Packages    This Package    Previous    Next