Java CharArrayWriter append() Example
CharArrayWriter class append() method example. This example shows you how to use append() method.
Syntax is : public CharArrayWriter append(char c)
This method 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)
Here is the code.
/**
* @(#) AppendCharArrayWriter.java
* A class representing use of method append() of CharArrayWriter() class in
java.io Package.
* @Version 31-May-2008
* @author Rose India Team
*/
import java.io.*;
public class AppendCharArrayWriter {
public static void main(String[] args){
// Create object of CharArrayWriter class.
CharArrayWriter objCharArrWriter = new CharArrayWriter();
// append() method call.
objCharArrWriter.append('M');
objCharArrWriter.append('A');
objCharArrWriter.append('H');
objCharArrWriter.append('E');
objCharArrWriter.append('N');
objCharArrWriter.append('D');
objCharArrWriter.append('R');
objCharArrWriter.append('A');
System.out.println("All characters are appended successfully!");
System.out.print("Elements in char buffer is : " + objCharArrWriter);
}
} |
Output of the program.
All characters are appended successfully!
Elements in char buffer is : MAHENDRA |
|