📜  java 读取文件文本 - Java 代码示例

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

代码示例1
try(BufferedReader br = new BufferedReader(new FileReader("file.txt"))) {
    StringBuilder sb = new StringBuilder();
    String line = br.readLine();

    while (line != null) {
        sb.append(line);
        sb.append(System.lineSeparator());
        line = br.readLine();
    }
    String everything = sb.toString();
}