com.cometway.io
Class StringBufferOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.cometway.io.StringBufferOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class StringBufferOutputStream
extends java.io.OutputStream

This extension of java.io.OutputStream writes to a StringBuffer. The StringBuffer passed in to the constructor of this class will be filled with the data written to this OutputStream.


Field Summary
protected  java.lang.StringBuffer buffer
           
protected  boolean closed
           
protected  java.lang.Object syncObject
           
 
Constructor Summary
StringBufferOutputStream(java.lang.StringBuffer out)
          The StringBuffer out will be filled with the data written to this OutputStream.
 
Method Summary
 void close()
          This method sets the closed flag.
 void flush()
          This method is blank.
 void write(byte[] b)
          Write an array of bytes.
 void write(byte[] b, int start, int length)
          Write an array of bytes starting from start and writes length number of bytes.
 void write(int b)
          Write a single byte.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected java.lang.StringBuffer buffer

syncObject

protected java.lang.Object syncObject

closed

protected boolean closed
Constructor Detail

StringBufferOutputStream

public StringBufferOutputStream(java.lang.StringBuffer out)
The StringBuffer out will be filled with the data written to this OutputStream.

Method Detail

close

public void close()
This method sets the closed flag. Once this OutputStream has been closed, no other data can be written to this OutputStream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream

flush

public void flush()
This method is blank. Data written to this OutputStream is always flushed.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream

write

public void write(int b)
           throws java.io.IOException
Write a single byte. Throws an IOException if the stream has been closed or for some reason the OutputStream is out of sync.

Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Write an array of bytes. Throws an IOException if the stream has been closed or for some reason the OutputStream is out of sync.

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int start,
                  int length)
           throws java.io.IOException
Write an array of bytes starting from start and writes length number of bytes. Throws an IOException if the stream has been closed or for some reason the OutputStream is out of sync.

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException