Java IO Tutorial - Java Writer.append(char c)








Syntax

Writer.append(char c) has the following syntax.

public Writer append(char c)  throws IOException

Example

In the following code shows how to use Writer.append(char c) method.

/*from  w w w.  j  a  v a 2s .  c  o m*/
import java.io.*;

public class Main {

   public static void main(String[] args) {
      char c = 'A';

      
      Writer writer = new PrintWriter(System.out);

      try {
         // append a char
         writer.append('c');

         // append a new char
         writer.append(c);

         // flush the writer to see the result
         writer.flush();

      } catch (IOException ex) {
         ex.printStackTrace();
      }
   }
}

The code above generates the following result.