Package org.codehaus.groovy.runtime
Class StringBufferWriter
java.lang.Object
java.io.Writer
org.codehaus.groovy.runtime.StringBufferWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
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
-
Constructor Summary
ConstructorDescriptionStringBufferWriter
(StringBuffer buffer) Create a new string writer which will append the text to the given StringBuffer -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closing a StringWriter has no effect.void
flush()
Flush the stream.toString()
Return the buffer's current value as a string.void
write
(char[] text, int offset, int length) Write a portion of an array of characters.void
write
(int c) Write a single character.void
Write a string.void
Write a portion of a string.
-
Constructor Details
-
StringBufferWriter
Create a new string writer which will append the text to the given StringBuffer
-
-
Method Details
-
write
public void write(int c) Write a single character. -
write
public void write(char[] text, int offset, int length) Write a portion of an array of characters. -
write
Write a string. -
write
Write a portion of a string. -
toString
Return the buffer's current value as a string. -
flush
public void flush()Flush the stream. -
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.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-