CharArrayWriter append() method in Java with Examples Last Updated : 05 Jun, 2020 Comments Improve Suggest changes Like Article Like Report The append() method of CharArrayWriter class in Java is of three types: The append(char) method of CharArrayWriter class in Java is used to append the specified character to the writer. This append() method appends one character at a time to the CharArrayWriter and returns this CharArrayWriter.Syntax: public CharArrayWriter append(char c) Specified By: This method is specified by the append() method of Appendable interface.Overrides: This method overrides the append() method of Writer class.Parameters: This method accepts one parameter c that represents the 16-bit character that is to be appended.Return value: This method returns CharArrayWriter after appending the character into it.Exceptions: This method does not throw any exception.Below program illustrates append(char) method in CharArrayWriter class in IO package:Program: Java // Java program to illustrate // CharArrayWriter append(char) method import java.io.*; public class GFG { public static void main(String[] args) { // Create charArrayWriter CharArrayWriter charArrayWriter = new CharArrayWriter(); // Append the character charArrayWriter.append('G'); charArrayWriter.append('E'); charArrayWriter.append('E'); charArrayWriter.append('K'); charArrayWriter.append('S'); // print the charArrayWriter System.out.println( charArrayWriter.toString()); } } Output: GEEKS The append(CharSequence) method of CharArrayWriter class in Java is used to append the specified character sequence to the writer. This append() method appends a character sequence at a time to the CharArrayWriter and returns this CharArrayWriter.Syntax: public CharArrayWriter append(CharSequence csq) Specified By: This method is specified by the append() method of Appendable interface.Overrides: This method overrides the append() method of Writer class.Parameters: This method accepts one parameter csq that represents the character sequence that is to be appended. If the character sequence is null then the 4 characters 'null' is appended to the CharArrayWriter.Return value: This method returns CharArrayWriter after appending the character sequence into it.Exceptions: This method does not throw any exception.Below program illustrates append(CharSequence) method in CharArrayWriter class in IO package:Program: Java // Java program to illustrate // CharArrayWriter append(CharSequence) method import java.io.*; public class GFG { public static void main(String[] args) { // Create charArrayWriter CharArrayWriter charArrayWriter = new CharArrayWriter(); // Create character sequence CharSequence csq1 = "GEEKS"; CharSequence csq2 = "FOR"; // Append character sequences // to the charArrayWriter charArrayWriter.append(csq1); charArrayWriter.append(csq2); charArrayWriter.append(csq1); // print the charArrayWriter System.out.println( charArrayWriter.toString()); } } Output: GEEKSFORGEEKS The append(CharSequence, int, int) method of CharArrayWriter class in Java is used to append the subsequence of a specified character sequence to the writer. This append() method appends a portion of character sequence to the CharArrayWriter and returns this CharArrayWriter.Syntax: public CharArrayWriter append(CharSequence csq, int start, int end) Specified By: This method is specified by the append() method of Appendable interface.Overrides: This method overrides the append() method of Writer class.Parameters: This method accepts three parameters: csq - It represents the character sequence whose subsequence is to be appended.start - It represents the starting index for the subsequence.end - It represents the index of character following the end for the subsequence. Return value: This method returns CharArrayWriter after appending the subsequence of the given character sequence into it.Exceptions: This method throws IndexOutOfBoundsException if the start or the end are negative or start is greater than end or end is greater than the length of given character sequence.Below program illustrates append(CharSequence, int, int) method in CharArrayWriter class in IO package:Program: Java // Java program to illustrate // CharArrayWriter // append(CharSequence, int, int) method import java.io.*; public class GFG { public static void main(String[] args) { // Create charArrayWriter CharArrayWriter charArrayWriter = new CharArrayWriter(); // Create character sequence CharSequence csq = "GEEKSFORGEEKS"; // Append subsequence of character // sequence to the charArrayWriter charArrayWriter.append(csq, 8, 13); // print the charArrayWriter System.out.println( charArrayWriter.toString()); } } Output: GEEKS References: 1. https://docs.oracle.com/javase/10/docs/api/java/io/CharArrayWriter.html#append(char) 2. https://docs.oracle.com/javase/10/docs/api/java/io/CharArrayWriter.html#append(java.lang.CharSequence) 3. https://docs.oracle.com/javase/10/docs/api/java/io/CharArrayWriter.html#append(java.lang.CharSequence, int, int) Comment More infoAdvertise with us Next Article CharArrayWriter append() method in Java with Examples P pp_pankaj Follow Improve Article Tags : Java Java-Functions Java-IO package 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 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 CharBuffer append() methods in Java with Examples append(char c) The append(char c) method of java.nio.CharBuffer Class is used to append the specified char to this buffer (optional operation). An invocation of this method of the form dst.append(c) behaves in exactly the same way as the invocation dst.put(c) Syntax : public CharBuffer append(char c 6 min read CharArrayWriter toString() method in Java with examples 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: Progr 1 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