Java IO Tutorial - Java StringWriter .append ( CharSequence csq, int start, int end)








Syntax

StringWriter.append(CharSequence csq, int start, int end) has the following syntax.

public StringWriter append(CharSequence csq,   int start,   int end)

Example

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

// ww w .j  a v  a 2s .c om
import java.io.*;

public class Main {

   public static void main(String[] args) {

      
      StringWriter sw = new StringWriter();

      CharSequence sq = "tutorial from java2s.com";

      // append sequence
      sw.append(sq, 0, 5);

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

      // append second sequence
      sw.append(sq, 6, 5);

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

   }
}

The code above generates the following result.