import java.io.*;
class FileReaderTest
{
public static void main(String[] args)
{
//System.out.println("Hello World!");
FileReader fr = null;
try
{
fr = new FileReader("DateDemo.java");
char[] buf = new char[1024];
int num = 0;
while ((num = fr.read(buf))!= -1) {
System.out.println(new String(buf,0,num));
}
}
catch (FileNotFoundException e)
{
System.out.println(e.toString());
}
finally
{
try
{
if(fr != null)
fr.close();
}
catch (FileNotFoundException e)
{
System.out.println(e.toString());
}
}
}
}错误: 未报告的异常错误IOException; 必须对其进行捕获或声明以便抛出,不是已经try和catch了吗?怎么还提示错误呢?
还应该在哪里生命呢??
|
|