CharArrayWriter toString() method in Java with examples Last Updated : 01 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The toString() method of the CharArrayWriter class in Java converts the given input data to a string. Syntax: public String[] toString() Parameters: This method does not accept any parameter. Return Value: This method returns a copy of the input data. Below program illustrate the above method: Program 1: Java // Java program to illustrate the // above mentioned method import java.io.*; public class GFG { public static void main(String[] args) throws IOException { // Initializing String Witer CharArrayWriter geek_writer1 = new CharArrayWriter(); CharSequence char_sq1 = "geeks for + "; CharSequence char_sq2 = "geeks"; // Use of append(CharSequence char_sq) geek_writer1.append(char_sq1); geek_writer1.append(char_sq2); // Convert it into string and print System.out.println("String : " + geek_writer1.toString()); } } Output: String : geeks for + geeks Program 2: Java // Java program to illustrate the // above mentioned method import java.io.*; public class GFG { public static void main(String[] args) throws IOException { // Initializing String Witer CharArrayWriter geek_writer1 = new CharArrayWriter(); CharSequence char_sq1 = "Gopal "; CharSequence char_sq2 = "Dave"; // Use of append(CharSequence char_sq) geek_writer1.append(char_sq1); geek_writer1.append(char_sq2); // Convert it into string and print System.out.println("String : " + geek_writer1.toString()); } } Output: String : Gopal Dave Reference: https://docs.oracle.com/javase/10/docs/api/java/io/CharArrayWriter.html#toString() Comment More infoAdvertise with us Next Article CharArrayWriter toString() method in Java with examples G gopaldave Follow Improve Article Tags : Java Java-Functions Java-IO package Java-CharArrayWriter Practice Tags : Java Similar Reads CharArrayWriter size() method in Java with examples The size() method of the CharArrayWriter class in Java is used to get the current size of the buffer. Syntax: public int size() Parameters: This method does not accept any parameter.Return Value: This method returns an integer value which signifies the current size of the buffer. Below program illus 2 min read CharArrayWriter toCharArray() method in Java with examples The toCharArray() method of the CharArrayWriter class in Java returns a copy of the input data.Syntax: public char[] toCharArray() Parameters: This method does not accept any parameter.Return Value: This method returns a copy of the input data. Below program illustrate the above method: Program 1: J 2 min read Charset toString() method in Java with Examples The toString() method is a built-in method of the java.nio.charset returns a string which describes the charset involved. Syntax: public final String toString() Parameters: The function does not accepts any parameter. Return Value: The function returns a string describing this charset. Below is the 1 min read CharArrayWriter write() method in Java with Examples The write() method of CharArrayWriter class in Java is of three types: The write(int) method of CharArrayWriter class in Java is used to write a character to the writer in form of an integer. This write() method writes one character at a time to the CharArrayWriter.Syntax: public void write(int c) O 3 min read CharArrayWriter writeTo() method in Java with Examples The writeTo(Writer) method of CharArrayWriter class in Java is used to write the contents of the CharArrayWriter to another character stream.Syntax: public void writeTo(Writer out) throws IOException Parameters: This method accepts one parameter out that represents the output stream that is the dest 1 min read Like