jodd.io
Class StringOutputStream

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

public class StringOutputStream
extends java.io.OutputStream
implements java.io.Serializable

Provides an OutputStream to an internal String. Internally converts bytes to a Strings and stores them in an internal StringBuffer.

See Also:
Serialized Form

Field Summary
protected  java.lang.StringBuffer buf
          The internal destination StringBuffer.
 
Constructor Summary
StringOutputStream()
          Creates new StringOutputStream, makes a new internal StringBuffer.
 
Method Summary
 void close()
          Sets the internal StringBuffer to null.
 java.lang.String toString()
          Returns the content of the internal StringBuffer as a String, the result of all writing to this OutputStream.
 void write(byte[] b)
          Writes and appends byte array to StringOutputStream.
 void write(byte[] b, int off, int len)
          Writes and appends a byte array to StringOutputStream.
 void write(int b)
          Writes and appends a single byte to StringOutputStream.
 
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 java.lang.StringBuffer buf
The internal destination StringBuffer.

Constructor Detail

StringOutputStream

public StringOutputStream()
Creates new StringOutputStream, makes a new internal StringBuffer.

Method Detail

toString

public java.lang.String toString()
Returns the content of the internal StringBuffer as a String, the result of all writing to this OutputStream.

Overrides:
toString in class java.lang.Object
Returns:
returns the content of the internal StringBuffer

close

public void close()
Sets the internal StringBuffer to null.

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

write

public void write(byte[] b)
Writes and appends byte array to StringOutputStream.

Overrides:
write in class java.io.OutputStream
Parameters:
b - byte array

write

public void write(byte[] b,
                  int off,
                  int len)
Writes and appends a byte array to StringOutputStream.

Overrides:
write in class java.io.OutputStream
Parameters:
b - the byte array
off - the byte array starting index
len - the number of bytes from byte array to write to the stream

write

public void write(int b)
Writes and appends a single byte to StringOutputStream.

Specified by:
write in class java.io.OutputStream
Parameters:
b - the byte as an int to add


Copyright ©2008 Jodd Team