- public static void FileReaderDemo2()
- {
- FileReader fr=null;
- try
- {
- fr =new FileReader("d:\\who.txt");
- char[] buf =new char[1024];
- int num =0;
- while ((num=fr.read(buf))!=-1)
- {
- sop(new String(buf,0,num));
- }
- }
- catch (IOException e)
- {
- sop("catch:"+e.toString());
- }
- finally
- {
- try
- {
- fr.close();
- }
- catch (IOException e)
- {
- sop("finally catch:"+e.toString());
- }
- }
-
- }
复制代码 |