Java 11

String methods

final var msg = "Hello "
          + System.lineSeparator()
          + "    my name is"
          + System.lineSeparator()
          + "    "
          + System.lineSeparator()
          + "Jimmy";

    final List<String> lines = msg.lines()
      .filter(s -> !s.isBlank())
      .map(String::strip)
      .toList();
    System.out.println(lines);
[Hello, my name is, Jimmy]

Files

String content = Files.readString(Path.of("src/main/resources/a.txt"));
    System.out.println(content);

// Same with writeString()
Hello World