import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class ReadLargeTextFile { public static void main(String[] args) { File file = new File("large_file.txt"); try (BufferedReader br = new BufferedReader(new FileReader(file))) { String line; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException e) { System.out.println("读取文件时发生错误:" + e.getMessage()); } } } }
标签:file,java,类来,new,BufferedReader,io,import,Java From: https://www.cnblogs.com/herd/p/17535588.html