Java.io.CharArrayWriter.write string() 方法


Java.io.CharArrayWriter.write string() 方法

package com.codingdict;



import java.io.CharArrayWriter;



public class CharArrayWriterDemo {



   public static void main(String[] args) {      

      String str = "Hello World!!";

      CharArrayWriter chw = null;



      try {



         // create character array writer

         chw = new CharArrayWriter();



         // portion to be written to writer

         chw.write(str, 4, 9);



         // print the buffer as string

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



      } catch(Exception e) {



         // for any error

         e.printStackTrace();

      } finally {



         // releases all system resources from writer

         if(chw!=null)

            chw.close();

      }

   }

}