[Java] BufferedReader(new FileReader( )) 从文件输入数据

import java.io.*;
public class InputStreamReaderFromFile{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new FileReader("2.txt"));
        while(true){
            String str = br.readLine();
            if(str.equals("over")){
                System.exit(0);
            }
            System.out.println(str);
        }
    }
}

//注意 new BufferedReader(new FileReader("2.txt"));

你可能感兴趣的:(java,string,import,class)