本帖最后由 陌路行者 于 2013-7-8 20:28 编辑
- import java.io.*;
- class BufferedReaderDemo
- {
- public static void main(String[] args)
- {
- FileReader fr = null;
- BufferedReader bufr = null;
- try
- {
- fr = new FileReader("BufferedWriterDemo.txt");
- bufr = new BufferedReader(fr);
- String line = null;
- while((line=bufr.readLine())!=null);
- {
- System.out.print(line);
- }
- }
- catch (IOException e)
- {
- throw new RuntimeException("读取文件失败");
- }
- finally
- {
- if(bufr!=null)
- try
- {
- bufr.close();
- }
- catch (IOException e)
- {
- throw new RuntimeException("关闭读取文件失败");
- }
-
- }
- }
- }
复制代码 C:\Users\Admin\Desktop\新建文件夹 (3)>java BufferedReaderDemo
null
C:\Users\Admin\Desktop\新建文件夹 (3)>
想了半天也想不出个所以然来
|