Java.io.PrintWriter.append() Method
Description
The java.io.PrintWriter.append() method appends the specified character to this writer.
Declaration
Following is the declaration for java.io.PrintWriter.append() method
public PrintWriter append(char c)
Parameters
c -- The 16-bit character to append
Return Value
This method returns this writer
Exception
NA
Example
The following example shows the usage of java.io.PrintWriter.append() method.
package com.tutorialspoint;
import java.io.*;
public class PrintWriterDemo {
public static void main(String[] args) {
try {
// create a new stream at system
PrintWriter pw = new PrintWriter(System.out);
// append chars
pw.append('H');
pw.append('e');
pw.append('l');
pw.append('l');
pw.append('o');
// flush the writer
pw.flush();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Let us compile and run the above program, this will produce the following result
Hello