Java.io.Writer.append Subsequence() 方法


Java.io.Writer.append Subsequence() 方法

package com.codingdict;



import java.io.*;



public class WriterDemo {



   public static void main(String[] args) {

      CharSequence csq = "Hello World!";



      // create a new writer

      Writer writer = new PrintWriter(System.out);



      try {



         // append a subsequence and change line

         writer.append("This is an example\n", 11, 19);



         // flush the writer

         writer.flush();



         // append a new subsequence

         writer.append(csq, 0, 5);



         // flush the writer to see the result

         writer.flush();



      } catch (IOException ex) {

         ex.printStackTrace();

      }

   }

}