18.字符数组流(只做了解)

public class BufferArrayDemo {
    
    public static void main(String[] args) throws IOException {
        
        //字符数组流
        CharArrayWriter caw = new CharArrayWriter();
        caw.write("春风不过玉门关");
        char[] c = caw.toCharArray();
        
        CharArrayReader car = new CharArrayReader(c);
        System.out.println(car.read());
        System.out.println((char)car.read());
        System.out.println((char)car.read());
        System.out.println((char)car.read());
        System.out.println((char)car.read());
        System.out.println((char)car.read());
        System.out.println((char)car.read());
        System.out.println(car.read());

        caw.close();
        car.close();
    }
    
}

你可能感兴趣的:(18.字符数组流(只做了解))