Comments for https://horstmann.com/unblog/2023-04-09/index.html
Comments for: https://horstmann.com/unblog/2023-04-09/index.html
- SSteve Storey @stevestorey
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 itsreadLine()
method , in essence duplicating the behaviour ofFiles.readAllLines
but from an arbitrary Reader (often from an arbitraryInputStream
- perhaps one provided from aClassLoader.getResourceAsStream
call). I couldn't spot an equivalentreadAllLines
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!
- CCay Horstmann @cayhorstmann
If
in
is anyInputStream
, you can usenew Scanner(in).useDelimiter("\r?\n|\r").tokens().toList()