The Files class provides several methods for reading and writing files, simplifying file I/O operations.
Source Code
Path path = Paths.get("example.txt");
try {
List fileContent = Files.readAllLines(path, StandardCharsets.UTF_8);
fileContent.forEach(System.out::println);
} catch (IOException e) {
e.printStackTrace();
}