Java.io.CharArrayReader.close() 方法


Java.io.CharArrayReader.close() 方法

package com.codingdict;



import java.io.CharArrayReader;

import java.io.IOException;



public class CharArrayReaderDemo {



   public static void main(String[] args) {      CharArrayReader car = null;

      char[] ch = {'H', 'E', 'L', 'L', 'O'};



      try { 



         // create new character array reader

         car = new CharArrayReader(ch);



         // closes the character array stream

         car.close();



         // read the character array stream

         car.read();



      } catch(IOException e) {



         // if I/O error occurs

         System.out.print("Stream is already closed");

      } finally {



         // releases any system resources associated with the stream

         if(car!=null)

            car.close();

      }

   }

}