Methods Summary |
---|
public java.io.CharArrayWriter | append(java.lang.CharSequence csq)Appends the specified character sequence to this writer.
An invocation of this method of the form out.append(csq)
behaves in exactly the same way as the invocation
out.write(csq.toString())
Depending on the specification of toString for the
character sequence csq, the entire sequence may not be
appended. For instance, invoking the toString method of a
character buffer will return a subsequence whose content depends upon
the buffer's position and limit.
String s = (csq == null ? "null" : csq.toString());
write(s, 0, s.length());
return this;
|
public java.io.CharArrayWriter | append(java.lang.CharSequence csq, int start, int end)Appends a subsequence of the specified character sequence to this writer.
An invocation of this method of the form out.append(csq, start,
end) when csq is not null, behaves in
exactly the same way as the invocation
out.write(csq.subSequence(start, end).toString())
String s = (csq == null ? "null" : csq).subSequence(start, end).toString();
write(s, 0, s.length());
return this;
|
public java.io.CharArrayWriter | append(char c)Appends the specified character to this writer.
An invocation of this method of the form out.append(c)
behaves in exactly the same way as the invocation
out.write(c)
write(c);
return this;
|
public void | close()Close the stream. This method does not release the buffer, since its
contents might still be required. Note: Invoking this method in this class
will have no effect.
|
public void | flush()Flush the stream.
|
public void | reset()Resets the buffer so that you can use it again without
throwing away the already allocated buffer.
count = 0;
|
public int | size()Returns the current size of the buffer.
return count;
|
public char[] | toCharArray()Returns a copy of the input data.
synchronized (lock) {
return Arrays.copyOf(buf, count);
}
|
public java.lang.String | toString()Converts input data to a string.
synchronized (lock) {
return new String(buf, 0, count);
}
|
public void | write(int c)Writes a character to the buffer.
synchronized (lock) {
int newcount = count + 1;
if (newcount > buf.length) {
buf = Arrays.copyOf(buf, Math.max(buf.length << 1, newcount));
}
buf[count] = (char)c;
count = newcount;
}
|
public void | write(char[] c, int off, int len)Writes characters to the buffer.
if ((off < 0) || (off > c.length) || (len < 0) ||
((off + len) > c.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
}
synchronized (lock) {
int newcount = count + len;
if (newcount > buf.length) {
buf = Arrays.copyOf(buf, Math.max(buf.length << 1, newcount));
}
System.arraycopy(c, off, buf, count, len);
count = newcount;
}
|
public void | write(java.lang.String str, int off, int len)Write a portion of a string to the buffer.
synchronized (lock) {
int newcount = count + len;
if (newcount > buf.length) {
buf = Arrays.copyOf(buf, Math.max(buf.length << 1, newcount));
}
str.getChars(off, off + len, buf, count);
count = newcount;
}
|
public void | writeTo(java.io.Writer out)Writes the contents of the buffer to another character stream.
synchronized (lock) {
out.write(buf, 0, count);
}
|