public class CharArrayWriter extends Writer
Modifier and Type | Field and Description |
---|---|
protected char[] |
buf
The buffer where data is stored.
|
protected int |
count
The number of chars in the buffer.
|
Constructor and Description |
---|
CharArrayWriter()
Creates a new CharArrayWriter.
|
CharArrayWriter(int initialSize)
Creates a new CharArrayWriter with the specified initial size.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the stream.
|
void |
flush()
Flush the stream.
|
void |
reset()
Resets the buffer so that you can use it again without
throwing away the already allocated buffer.
|
int |
size()
Returns the current size of the buffer.
|
char[] |
toCharArray()
Returns a copy of the input data.
|
String |
toString()
Converts input data to a string.
|
void |
write(char[] c,
int off,
int len)
Writes characters to the buffer.
|
void |
write(int c)
Writes a character to the buffer.
|
void |
write(String str,
int off,
int len)
Write a portion of a string to the buffer.
|
void |
writeTo(Writer out)
Writes the contents of the buffer to another character stream.
|
protected char[] buf
protected int count
public CharArrayWriter()
public CharArrayWriter(int initialSize)
initialSize
- an int specifying the initial buffer size.IllegalArgumentException
- if initialSize is negativepublic void write(char[] c, int off, int len)
public void write(String str, int off, int len)
public void writeTo(Writer out) throws IOException
out
- the output stream to write toIOException
- If an I/O error occurs.public void reset()
public char[] toCharArray()
public int size()
public String toString()
public void flush()