Java IO Tutorial - Java PrintStream .append (CharSequence csq)








Syntax

PrintStream.append(CharSequence csq) has the following syntax.

public PrintStream append(CharSequence csq)

Example

In the following code shows how to use PrintStream.append(CharSequence csq) method.

//w w  w  .j  ava 2  s.  c  o  m

import java.io.*;

public class Main {

   public static void main(String[] args) {
      String s = "from java2s.com. ";

      
      PrintStream ps = new PrintStream(System.out);

      // append our strings
      ps.append(s);
      ps.append("This is an example.");

      // print the result
      ps.flush();
      ps.close();

   }
}

The code above generates the following result.