google / guava

Google core libraries for Java
Apache License 2.0
50.03k stars 10.86k forks source link

Add LineReader.lines() for parity with BufferedReader #6067

Open JanecekPetr opened 2 years ago

JanecekPetr commented 2 years ago

LineReader currently only has the readLine() method. However, already since Java 8 there's [lines()](https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/io/BufferedReader.html#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.

ritikBhandari commented 2 years ago

so there are 3 methods to be implemented: lines(), readAllLines() and getLineNumber(). Right?

JanecekPetr commented 2 years ago

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:

Let's only focus on lines() here.

ritikBhandari commented 2 years ago

Makes sense. So its lines() for now. Should I resolve it?

maxmielchen commented 2 years ago

I have added the lines method in this pull request https://github.com/google/guava/pull/6142 Can anyone review it.

ayushsinghal90 commented 1 year ago

I have raised a cr for this.