com.sun.xml.messaging.saaj.util
Class ByteOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.sun.xml.messaging.saaj.util.ByteOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public final class ByteOutputStream
extends java.io.OutputStream

Customized BufferedOutputStream.

Compared to BufferedOutputStream, this class:

  1. doesn't do synchronization
  2. allows access to the raw buffer
  3. almost no parameter check


    Field Summary
    protected  byte[] buf
              The buffer where data is stored.
    protected  int count
              The number of valid bytes in the buffer.
     
    Constructor Summary
    ByteOutputStream()
               
    ByteOutputStream(int size)
               
     
    Method Summary
     void close()
               
     byte[] getBytes()
               
     int getCount()
               
     ByteInputStream newInputStream()
               
     void reset()
               
     int size()
               
     byte[] toByteArray()
              Deprecated. because this is evil!
     java.lang.String toString()
              Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.
     void write(byte[] b)
               
     void write(byte[] b, int off, int len)
               
     void write(java.io.InputStream in)
              Copies all the bytes from this input into this buffer.
     void write(int b)
               
     void writeAsAscii(java.lang.String s)
              Writes a string as ASCII string.
     void writeTo(java.io.OutputStream out)
               
     
    Methods inherited from class java.io.OutputStream
    flush
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    buf

    protected byte[] buf
    The buffer where data is stored.


    count

    protected int count
    The number of valid bytes in the buffer.

    Constructor Detail

    ByteOutputStream

    public ByteOutputStream()

    ByteOutputStream

    public ByteOutputStream(int size)
    Method Detail

    write

    public void write(java.io.InputStream in)
               throws java.io.IOException
    Copies all the bytes from this input into this buffer.

    Throws:
    java.io.IOException

    write

    public void write(int b)
    Specified by:
    write in class java.io.OutputStream

    write

    public void write(byte[] b,
                      int off,
                      int len)
    Overrides:
    write in class java.io.OutputStream

    write

    public void write(byte[] b)
    Overrides:
    write in class java.io.OutputStream

    writeAsAscii

    public void writeAsAscii(java.lang.String s)
    Writes a string as ASCII string.


    writeTo

    public void writeTo(java.io.OutputStream out)
                 throws java.io.IOException
    Throws:
    java.io.IOException

    reset

    public void reset()

    toByteArray

    public byte[] toByteArray()
    Deprecated. because this is evil!

    Evil buffer reallocation method. Don't use it unless you absolutely have to.


    size

    public int size()

    newInputStream

    public ByteInputStream newInputStream()

    toString

    public java.lang.String toString()
    Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.

    Overrides:
    toString in class java.lang.Object
    Returns:
    String translated from the buffer's contents.
    Since:
    JDK1.1

    close

    public void close()
    Specified by:
    close in interface java.io.Closeable
    Overrides:
    close in class java.io.OutputStream

    getBytes

    public byte[] getBytes()

    getCount

    public int getCount()