Reading files

suggest change

Files can be read byte- and line-wise using the Files class.

Path p2 = Paths.get(URI.create("file:///home/testuser/File.txt"));
byte[] content = Files.readAllBytes(p2);
List<String> linesOfContent = Files.readAllLines(p2);

Files.readAllLines() optionally takes a charset as parameter (default is StandardCharsets.UTF_8):

List<String> linesOfContent = Files.readAllLines(p2, StandardCharsets.ISO_8859_1);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents