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


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

package com.codingdict;



import java.io.CharArrayWriter;



public class CharArrayWriterDemo {



   public static void main(String[] args) {      

      int i = 0;

      String str = "";

      CharArrayWriter chw = null;



      try {



         // create character array writer

         chw = new CharArrayWriter();



         // from integer 65 to 69

         for(i = 65; i<70; i++) {



            // write integer to writer

            chw.write(i);



            // get the default character set value

            str = chw.toString();



            // print the string

            System.out.println(str);

         }



      } catch(Exception e) {



         // for any error

         e.printStackTrace();

      } finally {



         // releases all system resources from writer

         if(chw!=null)

            chw.close();

      }

   }

}