Java.io.Writer.write char len() 方法


Java.io.Writer.write char len() 方法

package com.codingdict;



import java.io.*;



public class WriterDemo {



   public static void main(String[] args) {

      char[] c = {'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd'};



      // create a new writer

      Writer writer = new PrintWriter(System.out);



      try {



         // write a portion of a char array

         writer.write(c, 0, 5);



         // flush the writer

         writer.flush();



         // write another portion of a char array

         writer.write(c, 5, 5);



         // flush the stream again

         writer.close();



      } catch (IOException ex) {

         ex.printStackTrace();

      }

   }

}