Advertisement
VADMARK

Read text file

Feb 19th, 2020
628
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.24 KB | None | 0 0
  1. StringBuilder contentBuilder = new StringBuilder();
  2. try (Stream<String> stream = Files.lines(Paths.get("test.txt"), StandardCharsets.UTF_8)) {
  3.     stream.forEach(s -> contentBuilder.append(s).append("\n"));
  4. }
  5. System.out.println(contentBuilder);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement