import java.io.*;
class FileReaderDemo
{
public static void main(String[] args) throws IOException
{
FileReader fr=null;
try{
fr = new FileReader("demo.txt");
int ch = 0;
while ((ch=fr.read())!=-1)
{
System.out.println((char)ch);
}
} catch(IOException e){
throw new RuntimeExceptin("失败");
}
finally{
if(fr!=null)
try{fr.close()}
catch(IOException e){
throw new RuntimeException("失败");
}
}
}
} |