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








Syntax

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

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

Example

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

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

public class Main {

   public static void main(String[] args) {
      CharSequence sq1 = "Hello";
      CharSequence sq2 = " World";

      
      PrintWriter pw = new PrintWriter(System.out);

      // append the sequence
      pw.append(sq1, 1, 3);
      pw.append(sq2, 1, 4);

      // flush the writer
      pw.flush();

   }
}

The code above generates the following result.