try (BufferedReader br = new BufferedReader(new FileReader("file.txt"))) { String line = br.readLine(); while (line != null) { System.out.println(line); line = br.readLine(); } }