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.


//ww w. ja  va  2s . c om

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.