Class: java.io.CharArrayWriter
- public class CharArrayWriter
- extends Writer
Note: Invoking close() on this class has no effect, and methods of this class can be called after the stream has closed without generating an IOException.
Methods
-
CharArrayWritertop
public CharArrayWriter()Creates a new CharArrayWriter. -
CharArrayWritertop
public CharArrayWriter(int initialSize)Creates a new CharArrayWriter with the specified initial size. -
appendtop
public CharArrayWriter append(char c)Appends the specified character to this writer.An invocation of this method of the form out.append(c) behaves in exactly the same way as the invocation
out.write(c)- Specified by:
- append from Appendable
-
appendtop
public CharArrayWriter append(CharSequence csq)Appends the specified character sequence to this writer.An invocation of this method of the form out.append(csq) behaves in exactly the same way as the invocation
out.write(csq.toString())Depending on the specification of toString for the character sequence csq, the entire sequence may not be appended. For instance, invoking the toString method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.
- Specified by:
- append from Appendable
-
appendtop
public CharArrayWriter append(CharSequence csq, int start, int end)Appends a subsequence of the specified character sequence to this writer.An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation
out.write(csq.subSequence(start, end).toString())- Specified by:
- append from Appendable
-
closetop
public void close()Close the stream. This method does not release the buffer, since its contents might still be required. Note: Invoking this method in this class will have no effect. -
flushtop
public void flush()Flush the stream. -
resettop
public void reset()Resets the buffer so that you can use it again without throwing away the already allocated buffer. -
sizetop
public int size()Returns the current size of the buffer. -
toCharArraytop
public char[] toCharArray()Returns a copy of the input data. -
toStringtop
public String toString()Converts input data to a string. -
writetop
public void write(int c)Writes a character to the buffer. -
writetop
public void write(String str, int off, int len)Write a portion of a string to the buffer. -
writetop
public void write(char[] c, int off, int len)Writes characters to the buffer. -
writeTotop
public void writeTo(Writer out) throws IOExceptionWrites the contents of the buffer to another character stream.
