Methods Summary |
---|
public java.io.StringWriter | append(char c)Appends the character {@code c} to this writer's {@code StringBuffer}.
This method works the same way as {@link #write(int)}.
write(c);
return this;
|
public java.io.StringWriter | append(java.lang.CharSequence csq)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.
if (null == csq) {
append(TOKEN_NULL, 0, TOKEN_NULL.length());
} else {
append(csq, 0, csq.length());
}
return this;
|
public java.io.StringWriter | append(java.lang.CharSequence csq, int start, int end)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.
if (null == csq) {
csq = TOKEN_NULL;
}
String output = csq.subSequence(start, end).toString();
write(output, 0, output.length());
return this;
|
public void | close()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.
/* empty */
|
public void | flush()Calling this method has no effect.
/* empty */
|
public java.lang.StringBuffer | getBuffer()Gets a reference to this writer's internal {@link StringBuffer}. Any
changes made to the returned buffer are reflected in this writer.
synchronized (lock) {
return buf;
}
|
public java.lang.String | toString()Gets a copy of the contents of this writer as a string.
synchronized (lock) {
return buf.toString();
}
|
public void | write(java.lang.String str, int offset, int count)Writes {@code count} characters from {@code str} starting at {@code
offset} to this writer's {@code StringBuffer}.
String sub = str.substring(offset, offset + count);
synchronized (lock) {
buf.append(sub);
}
|
public void | write(char[] cbuf, int offset, int count)Writes {@code count} characters starting at {@code offset} in {@code buf}
to this writer's {@code StringBuffer}.
// avoid int overflow
// BEGIN android-changed
// Exception priorities (in case of multiple errors) differ from
// RI, but are spec-compliant.
// removed redundant check, added null check, used (offset | count) < 0
// instead of (offset < 0) || (count < 0) to safe one operation
if (cbuf == null) {
throw new NullPointerException(Msg.getString("K0047")); //$NON-NLS-1$
}
if ((offset | count) < 0 || count > cbuf.length - offset) {
throw new IndexOutOfBoundsException(Msg.getString("K002f")); //$NON-NLS-1$
}
// END android-changed
synchronized (lock) {
this.buf.append(cbuf, offset, count);
}
|
public void | write(int oneChar)Writes one character to this writer's {@code StringBuffer}. Only the two
least significant bytes of the integer {@code oneChar} are written.
synchronized (lock) {
buf.append((char) oneChar);
}
|
public void | write(java.lang.String str)Writes the characters from the specified string to this writer's {@code
StringBuffer}.
synchronized (lock) {
buf.append(str);
}
|