try (Stream<String> stream = Files.lines(Paths.get(String.valueOf(new File("yourFile.txt"))))) { stream.forEach(System.out::println); } catch (IOException e) { e.printStackTrace(); }