[Java] Class StringBufferWriter

  • org.codehaus.groovy.runtime.StringBufferWriter

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.

Constructor Summary

Constructors
Constructor and description
StringBufferWriter (StringBuffer buffer)
Create a new string writer which will append the text to the given StringBuffer

Methods Summary

Methods
Type Params Return Type Name and description
void close()
Closing a StringWriter has no effect.
void flush()
Flush the stream.
String toString()
Return the buffer's current value as a string.
void write(int c)
Write a single character.
void write(char[] text, int offset, int length)
Write a portion of an array of characters.
void write(String text)
Write a string.
void write(String text, int offset, int length)
Write a portion of a string.

Inherited Methods Summary

Inherited Methods
Methods inherited from class Name
class Writer append, append, append, append, append, append, write, write, write, write, write, close, flush, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Constructor Detail

public StringBufferWriter(StringBuffer buffer)

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

Method Detail

public void 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.

public void flush()

Flush the stream.

public String toString()

Return the buffer's current value as a string.

public void write(int c)

Write a single character.

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

Write a portion of an array of characters.

Parameters:
text - Array of characters
offset - Offset from which to start writing characters
length - Number of characters to write

public void write(String text)

Write a string.

public void write(String text, int offset, int length)

Write a portion of a string.

Parameters:
text - the text to be written
offset - offset from which to start writing characters
length - Number of characters to write

© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/2.5.14/html/gapi/org/codehaus/groovy/runtime/StringBufferWriter.html