import java.io.*;
class ArrayReader{
CharArrayReader car; // 메모리의 문자 배열 객체에
CharArrayWriter caw; // 읽기 + 쓰기
String str;
ArrayReader(){
caw = new CharArrayWriter();
}
void write(){
str = "I am Civic";
try{
caw.write(str);
caw.flush();
}catch(IOException ioe){}
}
void read(){
char[] cs = caw.toCharArray();
/* for (char c : cs){ // 1. for 반복문
System.out.println("c : " + c);
}
*/
car = new CharArrayReader(cs);
int i = 0;
try{ // 2. while 반복문
while((i = car.read()) != -1){
System.out.println(" i : " + (char)i);
}
}catch(IOException ioe){}
}
public static void main(String[] args){
ArrayReader ar = new ArrayReader();
ar.write();
ar.read();
}
}