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








Syntax

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

public StringWriter append(CharSequence csq)

Example

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

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

public class Main {

   public static void main(String[] args) {

      
      StringWriter sw = new StringWriter();

      // create two new sequences
      CharSequence sq1 = "Hello";
      CharSequence sq2 = " World from java2s.com";

      // append sequence
      sw.append(sq1);

      System.out.println(sw.toString());

      // append second sequence
      sw.append(sq2);

      System.out.println(sw.toString());

   }
}

The code above generates the following result.