guava
guava copied to clipboard
Add LineReader.lines() for parity with BufferedReader
LineReader currently only has the readLine() method. However, already since Java 8 there's lines(), too.
Not to mention that it'd be nice to also maybe have readAllLines() and maybe even a getLineNumber() from LineNumberReader.
Yes, I know, there's CharStreams.readLines(), that's fine.
so there are 3 methods to be implemented: lines(), readAllLines() and getLineNumber(). Right?
Not really. I will say lines() definitely is needed to bring LineReader to where BufferedReader is. The other methods are up for a debate as they could be slightly controversial / unneeded:
- How often do you really need a line count? It's probably not worth it for the component to keep track of it all the time if only a small percentage of use-cases will use it.
- It's unclear whether
readAllLines()belongs here becauseCharStreams.readLines()exists. Doing one thing multiple ways is usually frowned upon in good API design. That said,LineReaderkinda screams for the method. Not my call. This requires more API designing and discussions and, let's be frank, nobody is going to spend precious time on arguing whether the method belongs there or not, so it's not going to be there.
Let's only focus on lines() here.
Makes sense. So its lines() for now.
Should I resolve it?
I have added the lines method in this pull request https://github.com/google/guava/pull/6142 Can anyone review it.
I have raised a cr for this.