org.apache.felix.ipojo.junit4osgi.plugin
Class StringOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.felix.ipojo.junit4osgi.plugin.StringOutputStream
All Implemented Interfaces:
Serializable

public class StringOutputStream
extends OutputStream
implements Serializable

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

Author:
Felix Project Team
See Also:
Serialized Form

Field Summary
protected  StringBuffer m_buffer
          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.
static char[] toCharArray(byte[] barr)
          Converts byte array to char array.
 String toString()
          Returns the content of the internal StringBuffer as a String, the result of all writing to this OutputStream.
 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.
 void write(String s)
          Writes and appends a String to StringOutputStream.
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_buffer

protected StringBuffer m_buffer
The internal destination StringBuffer.

Constructor Detail

StringOutputStream

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

Method Detail

toString

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

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

close

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

Overrides:
close in class OutputStream

write

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

Overrides:
write in class 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 OutputStream
Parameters:
b - the byte as an int to add

write

public void write(String s)
Writes and appends a String to StringOutputStream.

Parameters:
s - the String to add

toCharArray

public static char[] toCharArray(byte[] barr)
Converts byte array to char array.

Parameters:
barr - input byte array
Returns:
the char array corresponding to the given byte array


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.