import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class TestReadFile
{
public static void main(String[] args)
{
FileReader fr = null;
try
{
fr = new FileReader("e:/a.txt");
char c1 = (char) fr.read();
char c2 = (char) fr.read();
System.out.println(c1);
System.out.println(c2);
} catch (FileNotFoundException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}finally
{
try
{
if(fr != null)
fr.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
}
Java 文件读取的异常处理
最新推荐文章于 2023-10-11 22:47:48 发布