that writes characters to a {@code StringBuffer}
in a sequential manner, appending them in the process. The result can later
be queried using the
methods.
| Method from java.io.StringWriter Detail: |
public StringWriter append(char c) {
write(c);
return this;
}
Appends the character {@code c} to this writer's {@code StringBuffer}.
This method works the same way as #write(int) . |
public StringWriter append(CharSequence csq) {
if (null == csq) {
write(TOKEN_NULL);
} else {
write(csq.toString());
}
return this;
}
Appends the character sequence {@code csq} to this writer's {@code
StringBuffer}. This method works the same way as {@code
StringWriter.write(csq.toString())}. If {@code csq} is {@code null}, then
the string "null" is written to the target stream. |
public StringWriter append(CharSequence csq,
int start,
int end) {
if (null == csq) {
csq = TOKEN_NULL;
}
String output = csq.subSequence(start, end).toString();
write(output, 0, output.length());
return this;
}
Appends a subsequence of the character sequence {@code csq} to this
writer's {@code StringBuffer}. This method works the same way as {@code
StringWriter.writer(csq.subsequence(start, end).toString())}. If {@code
csq} is {@code null}, then the specified subsequence of the string "null"
will be written to the target. |
public void close() throws IOException {
/* empty */
}
Calling this method has no effect. In contrast to most {@code Writer} subclasses,
the other methods in {@code StringWriter} do not throw an {@code IOException} if
{@code close()} has been called. |
public void flush() {
/* empty */
}
Calling this method has no effect. |
public StringBuffer getBuffer() {
return buf;
}
Gets a reference to this writer's internal StringBuffer . Any
changes made to the returned buffer are reflected in this writer. |
public String toString() {
return buf.toString();
}
Gets a copy of the contents of this writer as a string. |
public void write(int oneChar) {
buf.append((char) oneChar);
}
Writes one character to this writer's {@code StringBuffer}. Only the two
least significant bytes of the integer {@code oneChar} are written. |
public void write(String str) {
buf.append(str);
}
Writes the characters from the specified string to this writer's {@code
StringBuffer}. |
public void write(char[] cbuf,
int offset,
int count) {
// avoid int overflow
if (offset < 0 || offset > cbuf.length || count < 0
|| count > cbuf.length - offset) {
throw new IndexOutOfBoundsException();
}
if (count == 0) {
return;
}
buf.append(cbuf, offset, count);
}
Writes {@code count} characters starting at {@code offset} in {@code buf}
to this writer's {@code StringBuffer}. |
public void write(String str,
int offset,
int count) {
String sub = str.substring(offset, offset + count);
buf.append(sub);
}
Writes {@code count} characters from {@code str} starting at {@code
offset} to this writer's {@code StringBuffer}. |