📜  使用 BufferedReader 读取 Java 中的文本文件 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:44.089000             🧑  作者: Mango

代码示例1
import java.io.*;

public class FileReaderWithBufferedReader {

    public static void main(String[] args) throws IOException{We
        String file = "src/file.txt";
        BufferedReader bufferedReader = new BufferedReader(new FileReader(file));

        String curLine;
        while ((curLine = bufferedReader.readLine()) != null){
            //process the line as required
            System.out.println(curLine);
        }
        bufferedReader.close();
    }
}