本帖最后由 orgcheng 于 2012-9-17 17:32 编辑
看下面的流的封装- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.Scanner;
- public class IODemo {
- public static void main(String[] args) throws IOException {
-
- File file = new File("input.txt");
- FileReader reader = new FileReader(file);
- BufferedReader bufferedReader = new BufferedReader(reader);
- Scanner cin = new Scanner(bufferedReader);
-
- String line = null;
- while((line = cin.nextLine())!=null){
- System.out.println(line);
- }
- }
- }
复制代码 这种封装是没问题的,但是既然打开,那就得关闭,但是关闭。。。先关闭那个,有点晕,求教 |