| java.lang.Object | ||
| ↳ | java.io.Writer | |
| ↳ | java.io.CharArrayWriter | |
CharArrayWriter is used as a character output stream on a character array. The buffer used to store the written characters will grow as needed to accommodate more characters as they are written.
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| buf | Buffer for characters | ||||||||||
| count | The ending index of the buffer. | ||||||||||
|
[Expand]
Inherited Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.io.Writer
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new CharArrayWriter which has a buffer allocated with the
default size of 32 characters.
| |||||||||||
Constructs a new CharArrayWriter which has a buffer allocated with the
size of
initialSize characters. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Append a char
cto the CharArrayWriter. | |||||||||||
Append a CharSequence
csq to the CharArrayWriter. | |||||||||||
Append a subsequence of a CharSequence
csq to the
CharArrayWriter. | |||||||||||
Close this Writer.
| |||||||||||
Flush this Writer.
| |||||||||||
Reset this Writer.
| |||||||||||
Answer the size of this Writer in characters.
| |||||||||||
Answer the contents of the receiver as a char array.
| |||||||||||
Answer the contents of this CharArrayWriter as a String.
| |||||||||||
Writes
count number of characters starting at
offset from the String str to this
CharArrayWriter. | |||||||||||
Writes the specified character
oneChar to this
CharArrayWriter. | |||||||||||
Writes
count characters starting at offset
in buf to this CharArrayWriter. | |||||||||||
Writes the contents of this CharArrayWriter to another Writer.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.io.Writer
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface java.io.Closeable
| |||||||||||
From interface java.io.Flushable
| |||||||||||
From interface java.lang.Appendable
| |||||||||||
Buffer for characters
The ending index of the buffer.
Constructs a new CharArrayWriter which has a buffer allocated with the
default size of 32 characters. The buffer is also the lock
used to synchronize access to this Writer.
Constructs a new CharArrayWriter which has a buffer allocated with the
size of initialSize characters. The buffer is also the
lock used to synchronize access to this Writer.
| initialSize | the initial size of this CharArrayWriters buffer. |
|---|
Append a char cto the CharArrayWriter. The
CharArrayWriter.append(c) works the same way as
CharArrayWriter.write(c).
| c | The character appended to the CharArrayWriter. |
|---|
Append a CharSequence csq to the CharArrayWriter. The
CharArrayWriter.append(csq) works the same way as
CharArrayWriter.write(csq.toString()). If
csq is null, then then "null" will be substituted for
csq.
| csq | The CharSequence appended to the CharArrayWriter. |
|---|
Append a subsequence of a CharSequence csq to the
CharArrayWriter. The first char and the last char of the subsequnce is
specified by the parameter start and end.
The CharArrayWriter.append(csq) works the same way as
CharArrayWriter.write(csq.subSequence(start,end).toString).
If csq is null, then "null" will be substituted for
csq.
| csq | The CharSequence appended to the CharArrayWriter. |
|---|---|
| start | The index of the first char in the CharSequence appended to the CharArrayWriter. |
| end | The index of the char after the last one in the CharSequence appended to the CharArrayWriter. |
| IndexOutOfBoundsException | If start is less than end, end is greater than the length of the CharSequence, or start or end is negative. |
|---|
Close this Writer. This is the concrete implementation required. This particular implementation does nothing.
Flush this Writer. This is the concrete implementation required. This particular implementation does nothing.
Reset this Writer. The current write position is reset to the beginning of the buffer. All written characters are lost and the size of this writer is now 0.
Answer the size of this Writer in characters. This number changes if this Writer is reset or as more characters are written to it.
Answer the contents of the receiver as a char array. The array returned is a copy and any modifications made to this Writer after are not reflected in the result.
Answer the contents of this CharArrayWriter as a String. The String returned is a copy and any modifications made to this Writer after are not reflected in the result.
Writes count number of characters starting at
offset from the String str to this
CharArrayWriter.
| str | the non-null String containing the characters to write. |
|---|---|
| offset | the starting point to retrieve characters. |
| len | the number of characters to retrieve and write. |
Writes the specified character oneChar to this
CharArrayWriter. This implementation writes the low order two bytes to
the Stream.
| oneChar | The character to write |
|---|
Writes count characters starting at offset
in buf to this CharArrayWriter.
| c | the non-null array containing characters to write. |
|---|---|
| offset | offset in buf to retrieve characters |
| len | maximum number of characters to write |
Writes the contents of this CharArrayWriter to another Writer. The output is all the characters that have been written to the receiver since the last reset or since the creation.
| out | the non-null Writer on which to write the contents. |
|---|
| IOException | If an error occurs attempting to write the contents out. |
|---|