The Java.io.CharArrayWriter class implements a character buffer that can be used as an Writer. The buffer automatically grows when data is written to the stream.
Following is the declaration for Java.io.CharArrayWriter class −
public class CharArrayWriter extends Writer
Following are the fields for Java.io.CharArrayWriter class −
protected char buf − This is the buffer where data is stored.
protected int count − This is the number of chars in the buffer.
protected Object lock − This is the object used to synchronize operations on this stream.
|S.N.||Constructor & Description|
This creates a CharArrayReader from the specified array of chars.
This creates a new CharArrayWriter with the specified initial size.
|S.N.||Method & Description|
|1||CharArrayWriter append(char c)
This method appends the specified character to this writer.
|2||CharArrayWriter append(CharSequence csq)
This method appends the specified character sequence to this writer.
|3||CharArrayWriter append(CharSequence csq, int start, int end)
This method appends a subsequence of the specified character sequence to this writer.
This method close the stream.
This method flush the stream.
This method resets the buffer so that you can use it again without throwing away the already allocated buffer.
This method returns the current size of the buffer.
This method returns a copy of the input data.
This method converts input data to a string.
|10||void write(char c, int off, int len)
This method writes characters to the buffer.
|11||void write(int c)
This method writes a character to the buffer.
|12||void write(String str, int off, int len)
This method write a portion of a string to the buffer.
|13||void writeTo(Writer out)
This method writes the contents of the buffer to another character stream.
This class inherits methods from the following classes −