Top Description Fields Constructors Methods
org.codehaus.groovy.runtime

public Class StringBufferWriter

extends Writer
Class Inheritance
Imports
java.io.IOException, .Writer

This class codes around a silly limitation of StringWriter which doesn't allow a StringBuffer to be passed in as a constructor for some bizarre reason. So we replicate the behaviour of StringWriter here but allow a StringBuffer to be passed in.

Field Summary

Modifier and TypeField and Description
private final StringBuffer
Inherited from java.io.Writer:
lock

Constructor Summary

AccessConstructor and Description
public
StringBufferWriter(StringBuffer buffer)

Create a new string writer which will append the text to the given StringBuffer

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closing a StringWriter has no effect.
public void
flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flush the stream.
public String
toString()

Overrides java.lang.Object.toString.

Return the buffer's current value as a string.
public void
write(int
int specifying a character to be written
c
)

Overrides java.io.Writer.write.

Write a single character.
public void
write(char[]
Array of characters
text
,
int
Offset from which to start writing characters
offset
,
int
Number of characters to write
length
)

Implements abstract java.io.Writer.write.

Write a portion of an array of characters.
public void
write(String
String to be written
text
)

Overrides java.io.Writer.write.

Write a string.
public void
write(String
the text to be written
text
,
int
offset from which to start writing characters
offset
,
int
Number of characters to write
length
)

Overrides java.io.Writer.write.

Write a portion of a string.
Inherited from java.io.Writer:
appendappendappendnullWriterwrite

Field Detail

bufferback to summary
private final StringBuffer buffer

Constructor Detail

StringBufferWriterback to summary
public StringBufferWriter(StringBuffer buffer)

Create a new string writer which will append the text to the given StringBuffer

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closing a StringWriter has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.

Exceptions
IOException:

Doc from java.io.Writer.close.

If an I/O error occurs

flushback to summary
public void flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flush the stream.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return the buffer's current value as a string.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

writeback to summary
public void write(int c)

Overrides java.io.Writer.write.

Write a single character.

Parameters
c:int

Doc from java.io.Writer.write.

int specifying a character to be written

writeback to summary
public void write(char[] text, int offset, int length)

Implements abstract java.io.Writer.write.

Write a portion of an array of characters.

Parameters
text:char[]

Array of characters

offset:int

Offset from which to start writing characters

length:int

Number of characters to write

writeback to summary
public void write(String text)

Overrides java.io.Writer.write.

Write a string.

Parameters
text:String

Doc from java.io.Writer.write.

String to be written

writeback to summary
public void write(String text, int offset, int length)

Overrides java.io.Writer.write.

Write a portion of a string.

Parameters
text:String

the text to be written

offset:int

offset from which to start writing characters

length:int

Number of characters to write