| java.lang.Object java.io.Writer java.io.CharArrayWriter
CharArrayWriter | public class CharArrayWriter extends Writer (Code) | | 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.
|
Field Summary | |
protected char[] | buf | protected int | count The ending index of the buffer. |
Constructor Summary | |
public | CharArrayWriter() Constructs a new CharArrayWriter which has a buffer allocated with the
default size of 32 characters. | public | CharArrayWriter(int initialSize) Constructs a new CharArrayWriter which has a buffer allocated with the
size of initialSize characters. |
Method Summary | |
public CharArrayWriter | append(char c) Append a char c to the CharArrayWriter. | public CharArrayWriter | append(CharSequence csq) Append a CharSequence csq to the CharArrayWriter. | public CharArrayWriter | append(CharSequence csq, int start, int end) Append a subsequence of a CharSequence csq to the
CharArrayWriter. | public void | close() Close this Writer. | public void | flush() Flush this Writer. | public void | reset() Reset this Writer. | public int | size() Answer the size of this Writer in characters. | public char[] | toCharArray() Answer the contents of the receiver as a char array. | public String | toString() Answer the contents of this CharArrayWriter as a String. | public void | write(char[] c, int offset, int len) Writes count characters starting at offset
in buf to this CharArrayWriter. | public void | write(int oneChar) Writes the specified character oneChar to this
CharArrayWriter. | public void | write(String str, int offset, int len) Writes count number of characters starting at
offset from the String str to this
CharArrayWriter. | public void | writeTo(Writer out) Writes the contents of this CharArrayWriter to another Writer. |
buf | protected char[] buf(Code) | | Buffer for characters
|
count | protected int count(Code) | | The ending index of the buffer.
|
CharArrayWriter | public CharArrayWriter()(Code) | | 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.
|
CharArrayWriter | public CharArrayWriter(int initialSize)(Code) | | 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.
Parameters: initialSize - the initial size of this CharArrayWriters buffer. |
append | public CharArrayWriter append(char c)(Code) | | Append a char c to the CharArrayWriter. The
CharArrayWriter.append(c ) works the same way as
CharArrayWriter.write(c ).
Parameters: c - The character appended to the CharArrayWriter. The CharArrayWriter. See Also: Writer.append(char) |
append | public CharArrayWriter append(CharSequence csq)(Code) | | 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 .
Parameters: csq - The CharSequence appended to the CharArrayWriter. The CharArrayWriter See Also: Writer.append(CharSequence) |
append | public CharArrayWriter append(CharSequence csq, int start, int end)(Code) | | 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 .
Parameters: csq - The CharSequence appended to the CharArrayWriter. Parameters: start - The index of the first char in the CharSequence appended tothe CharArrayWriter. Parameters: end - The index of the char after the last one in the CharSequenceappended to the CharArrayWriter. The CharArrayWriter. throws: IndexOutOfBoundsException - If start is less than end, end is greater than the length ofthe CharSequence, or start or end is negative. See Also: Writer.append(CharSequenceintint) |
close | public void close()(Code) | | Close this Writer. This is the concrete implementation required. This
particular implementation does nothing.
|
flush | public void flush()(Code) | | Flush this Writer. This is the concrete implementation required. This
particular implementation does nothing.
|
reset | public void reset()(Code) | | 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.
|
size | public int size()(Code) | | Answer the size of this Writer in characters. This number changes if this
Writer is reset or as more characters are written to it.
int this CharArrayWriters current size in characters. |
toCharArray | public char[] toCharArray()(Code) | | 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.
char[] this CharArrayWriters contents as a new char array. |
toString | public String toString()(Code) | | 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.
String this CharArrayWriters contents as a new String. |
write | public void write(char[] c, int offset, int len)(Code) | | Writes count characters starting at offset
in buf to this CharArrayWriter.
Parameters: c - the non-null array containing characters to write. Parameters: offset - offset in buf to retrieve characters Parameters: len - maximum number of characters to write |
write | public void write(int oneChar)(Code) | | Writes the specified character oneChar to this
CharArrayWriter. This implementation writes the low order two bytes to
the Stream.
Parameters: oneChar - The character to write |
write | public void write(String str, int offset, int len)(Code) | | Writes count number of characters starting at
offset from the String str to this
CharArrayWriter.
Parameters: str - the non-null String containing the characters to write. Parameters: offset - the starting point to retrieve characters. Parameters: len - the number of characters to retrieve and write. |
writeTo | public void writeTo(Writer out) throws IOException(Code) | | 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.
Parameters: out - the non-null Writer on which to write the contents. throws: IOException - If an error occurs attempting to write the contents out. |
|
|