equivalent to Files.readAllLines() for InputStream or Reader?

An InputStream represents a stream of bytes. Those bytes don’t necessarily form (text) content that can be read line by line.

If you know that the InputStream can be interpreted as text, you can wrap it in a InputStreamReader and use BufferedReader#lines() to consume it line by line.

try (InputStream resource = Example.class.getResourceAsStream("resource")) {
  List<String> doc =
      new BufferedReader(new InputStreamReader(resource,
          StandardCharsets.UTF_8)).lines().collect(Collectors.toList());
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)