Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
1
20
21
22
23
24
25
26
27
28
29
34
35
// {
// Method 1: for small files (load the entire file in memory)
List<String> lines = Files.readAllLines(Paths.get("file.txt"));
// Method 2: for big files (read line by line)
try (BufferedReader reader = Files.newBufferedReader(Paths.get("file.txt"), StandardCharsets.UTF_8)) {
reader.lines().forEach(System.out::println);
}
//{
Enter to Rename, Shift+Enter to Preview
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content