import java.io.*;
class ReaderExample1 {
public static void main(String args[]) {
FileReader reader = null;
try{
reader = new FileReader("poem.txt");
while(true) {
int date = reader.read();
if (date == 1)
break;
char ch = (char) date;
System.out.println(ch);
}
}
catch (FileNotFoundException fnfe) {
System.out.println("파일이 존재하지 않습니다.");
}
catch (IOException ioe) {
System.out.println("파일을 읽을 수 없습니다.");
}
finally{
try{
reader.close();
}
catch (Exception e) {
}
}
}
}
위는 예제 10-3입니다.
실행하는 디렉토리 안에 poem.txt라는 파일이 있습니다.
근데 결과는 물음표만 나오네요ㅠㅠ
제가 어떤 실수를 했는지 알려주셨으면합니다.