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








Syntax

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

public Writer append(CharSequence csq,  int start,  int end)  throws IOException

Example

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

//w  w w  . j ava 2s . c o  m
import java.io.*;

public class Main {

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

      
      Writer writer = new PrintWriter(System.out);

      try {
         writer.append("This is an example\n");

         // flush the writer
         writer.flush();

         // append a new sequence
         writer.append(csq,2,30);

         // flush the writer to see the result
         writer.flush();

      } catch (IOException ex) {
         ex.printStackTrace();
      }
   }
}

The code above generates the following result.