org.mmbase.util
Class StringBufferWriter

java.lang.Object
  extended byjava.io.Writer
      extended byorg.mmbase.util.StringBufferWriter

public class StringBufferWriter
extends java.io.Writer

Oddly enough, Java does not provide this itself. Code is nearly identical to java.io.StringWriter.

Since:
MMBase-1.7
Author:
Michiel Meeuwissen
See Also:
StringWriter

Field Summary
protected  java.lang.StringBuffer buf
           
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
StringBufferWriter(java.lang.StringBuffer buffer)
          Create a new stringbufferwriter
 
Method Summary
 void close()
          Closing a StringWriter has no effect.
 void flush()
          Flush the stream.
 java.lang.StringBuffer getBuffer()
          Return the string buffer itself.
 java.lang.String toString()
          Return the buffer's current value as a string.
 void write(char[] cbuf, int off, int len)
          Write a portion of an array of characters.
 void write(int c)
          Write a single character.
 void write(java.lang.String str)
          Write a string.
 void write(java.lang.String str, int off, int len)
          Write a portion of a string.
 
Methods inherited from class java.io.Writer
write
 
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
Constructor Detail

StringBufferWriter

public StringBufferWriter(java.lang.StringBuffer buffer)
Create a new stringbufferwriter

Method Detail

write

public void write(int c)
Write a single character.


write

public void write(char[] cbuf,
                  int off,
                  int len)
Write a portion of an array of characters.

Parameters:
cbuf - Array of characters
off - Offset from which to start writing characters
len - Number of characters to write

write

public void write(java.lang.String str)
Write a string.


write

public void write(java.lang.String str,
                  int off,
                  int len)
Write a portion of a string.

Parameters:
str - String to be written
off - Offset from which to start writing characters
len - Number of characters to write

toString

public java.lang.String toString()
Return the buffer's current value as a string.


getBuffer

public java.lang.StringBuffer getBuffer()
Return the string buffer itself.

Returns:
StringBuffer holding the current buffer value.

flush

public void flush()
Flush the stream.


close

public void close()
           throws java.io.IOException
Closing a StringWriter has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.

Throws:
java.io.IOException


MMBase build 1.7.1.20041002