java.io
public class StringWriter extends Writer
StringBuffer
that
can then be used to retrieve a String
.
Constructor Summary | |
---|---|
StringWriter()
This method initializes a new StringWriter to write to a
StringBuffer initially sized to a default size of 16
chars. | |
StringWriter(int size)
This method initializes a new StringWriter to write to a
StringBuffer with the specified initial size.
|
Method Summary | |
---|---|
StringWriter | append(char c) |
StringWriter | append(CharSequence cs) |
StringWriter | append(CharSequence cs, int start, int end) |
void | close()
This method closes the stream. |
void | flush()
This method flushes any buffered characters to the underlying output.
|
StringBuffer | getBuffer()
This method returns the StringBuffer object that this
object is writing to. |
String | toString()
This method returns the contents of the internal StringBuffer
as a String .
|
void | write(int oneChar)
This method writes a single character to the output, storing it in
the internal buffer.
|
void | write(char[] chars, int offset, int len)
This method writes len chars from the specified
array starting at index offset in that array to this
stream by appending the chars to the end of the internal buffer.
|
void | write(String str)
This method writes the characters in the specified String
to the stream by appending them to the end of the internal buffer.
|
void | write(String str, int offset, int len)
This method writes out len characters of the specified
String to the stream starting at character position
offset into the stream. |
StringWriter
to write to a
StringBuffer
initially sized to a default size of 16
chars.StringWriter
to write to a
StringBuffer
with the specified initial size.
Parameters: size The initial size to make the StringBuffer
Since: 1.5
Since: 1.5
Since: 1.5
Throws: IOException If an error orrurs.
StringBuffer
object that this
object is writing to. Note that this is the actual internal buffer, so
any operations performed on it will affect this stream object.
Returns: The StringBuffer
object being written to
StringBuffer
as a String
.
Returns: A String
representing the chars written to
this stream.
Parameters: oneChar The char
to write, passed as an int.
len
chars from the specified
array starting at index offset
in that array to this
stream by appending the chars to the end of the internal buffer.
Parameters: chars The array of chars to write offset The index into the array to start writing from len The number of chars to write
String
to the stream by appending them to the end of the internal buffer.
Parameters: str The String
to write to the stream.
len
characters of the specified
String
to the stream starting at character position
offset
into the stream. This is done by appending the
characters to the internal buffer.
Parameters: str The String
to write characters from offset The character position to start writing from len The number of characters to write.