No internet connection
  1. Home

Comments for https://horstmann.com/unblog/2023-04-09/index.html

By System @system
    2023-05-09 21:31:53.591Z
    • 2 comments
    1. S
      Steve Storey @stevestorey
        2023-05-09 21:31:53.676Z

        Thanks for the helpful post - highlights a few things I'd either forgotten about or was unaware of.

        One point tho - I find myself using BufferedReader and a while loop in order to use its readLine() method , in essence duplicating the behaviour of Files.readAllLines but from an arbitrary Reader (often from an arbitrary InputStream - perhaps one provided from a ClassLoader.getResourceAsStream call). I couldn't spot an equivalent readAllLines method on any of the stream based classes, but have I missed something? (I believe there's a Guava equivalent and an Apache Commons IO equivalent, but I would hope to avoid unnecessarily including those JARs in my project just for a simple loop utility ...)

        Thank again!

        1. CCay Horstmann @cayhorstmann
            2023-05-10 04:44:21.934Z

            If in is any InputStream, you can use new Scanner(in).useDelimiter("\r?\n|\r").tokens().toList()