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
BufferedReaderand a while loop in order to use itsreadLine()method , in essence duplicating the behaviour ofFiles.readAllLinesbut from an arbitrary Reader (often from an arbitraryInputStream- perhaps one provided from aClassLoader.getResourceAsStreamcall). I couldn't spot an equivalentreadAllLinesmethod 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
inis anyInputStream, you can usenew Scanner(in).useDelimiter("\r?\n|\r").tokens().toList()