hussam.io
Class StringOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by hussam.io.StringOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class StringOutputStream
extends java.io.OutputStream

This is an output stream that prints to any StringAppendable.

Author:
حسام الملحم Hussam Al-Mulhim

Constructor Summary
StringOutputStream(StringAppendable viewer)
          Constructs a StringOutputStream that prints to a StringAppendable with a default of 1000 flushSize.
StringOutputStream(StringAppendable viewer, int flushSize)
          Constructs a StringOutputStream that prints to a StringAppendable with a given flushSize
 
Method Summary
 void close()
          Closes this stream.
 void flush()
          Flushes the stream.
protected  byte[] getArray()
          returns an array containing all bytes in the stream which were not flushed yet.
 void write(int bytee)
          Writes the given byte supplied as an int.
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringOutputStream

public StringOutputStream(StringAppendable viewer,
                          int flushSize)
Constructs a StringOutputStream that prints to a StringAppendable with a given flushSize


StringOutputStream

public StringOutputStream(StringAppendable viewer)
Constructs a StringOutputStream that prints to a StringAppendable with a default of 1000 flushSize.

Method Detail

write

public void write(int bytee)
Writes the given byte supplied as an int.

Specified by:
write in class java.io.OutputStream

close

public void close()
Closes this stream. The current implementation only flushes the stream.

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

flush

public void flush()
Flushes the stream.

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

getArray

protected byte[] getArray()
returns an array containing all bytes in the stream which were not flushed yet.