CharArrayWriter class methods in Java

java.io.CharArrayWriter

This class implements a character buffer that can be used as a Writer. The buffer automatically grows when data is written to the stream.

Note: The data can be retrieved using toCharArray() and toString().


Some methods of CharArrayWriter class.


append(char): This method appends the specified character to this writer.


append(CharSequence): This method appends the specified character sequence to this writer.


append(CharSequence, int, int): This method appends a subsequence of the specified character sequence to this writer.


close(): This method does not release the buffer, since its contents might still be required.


flush(): This method flushes the stream.


reset(): This method resets the buffer so that you can use it again without throwing away the already allocated buffer.


size(): This method returns the current size of the buffer.


toCharArray(): This method returns a copy of the input data.


toString(): This method converts input data to a string.


write(int): This method writes a character to the buffer.


write(char[], int, int): This method writes characters to the buffer.


write(String, int, int): This method writes a portion of a string to the buffer.


writeTo(Writer): This method writes the contents of the buffer to another character stream.


No comments:

Post a Comment