Package org.codehaus.groovy.runtime
Class StringBufferWriter
- java.lang.Object
-
- java.io.Writer
-
- org.codehaus.groovy.runtime.StringBufferWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.Appendable
,java.lang.AutoCloseable
public class StringBufferWriter extends java.io.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.
-
-
Constructor Summary
Constructors Constructor Description StringBufferWriter(java.lang.StringBuffer buffer)
Create a new string writer which will append the text to the given StringBuffer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closing a StringWriter has no effect.void
flush()
Flush the stream.java.lang.String
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(java.lang.String text)
Write a string.void
write(java.lang.String text, int offset, int length)
Write a portion of a string.
-
-
-
Method Detail
-
write
public void write(int c)
Write a single character.- Overrides:
write
in classjava.io.Writer
-
write
public void write(char[] text, int offset, int length)
Write a portion of an array of characters.- Specified by:
write
in classjava.io.Writer
- Parameters:
text
- Array of charactersoffset
- Offset from which to start writing characterslength
- Number of characters to write
-
write
public void write(java.lang.String text)
Write a string.- Overrides:
write
in classjava.io.Writer
-
write
public void write(java.lang.String text, int offset, int length)
Write a portion of a string.- Overrides:
write
in classjava.io.Writer
- Parameters:
text
- the text to be writtenoffset
- offset from which to start writing characterslength
- Number of characters to write
-
toString
public java.lang.String toString()
Return the buffer's current value as a string.- Overrides:
toString
in classjava.lang.Object
-
flush
public void flush()
Flush the stream.- Specified by:
flush
in interfacejava.io.Flushable
- Specified by:
flush
in classjava.io.Writer
-
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.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Writer
- Throws:
java.io.IOException
-
-