writeTo(Writer): This method is available in the java.io.CharArrayWriter class of Java.
Syntax:
void java.io.CharArrayWriter.writeTo(Writer out) throws IOException
This method takes one argument. This method writes the contents of the buffer to another character stream.
Parameters: One parameter is required for this method.
out: the output stream to write to.
Returns: NA
Throws: IOException - If an I/O error occurs.
Approach
Java
import java.io.CharArrayWriter;import java.io.IOException;public class CharArrayWriterwriteTo {public static void main(String[] args) throws IOException {CharArrayWriter charArrayWriter = new CharArrayWriter();char cbuf[] = { 'a', 'b', 'c', 'd' };charArrayWriter.write(cbuf);CharArrayWriter out = new CharArrayWriter();charArrayWriter.writeTo(out);System.out.println(out.toString());charArrayWriter.close();}}
Output:
abcd
No comments:
Post a Comment