RFR JDK-8003258: BufferedReader.lines() (original) (raw)

Remi Forax forax at univ-mlv.fr
Sat Apr 27 08:35:16 UTC 2013


On 04/27/2013 01:46 AM, Stephen Colebourne wrote:

I would suggest a new line at the end of each file.

Plus there is some very stylised formatting in terms of making things align vertically that I wouldn't do personally, and seem to waste a lot of screen space. Plus a single line which should be three lines. public void close() { closed = true; } "Since the {@code Stream} does not necessary consume all lines" should be "Since the {@code Stream} does not necessarily consume all lines" I did a double take when I saw: try { return nextLine; } finally { nextLine = null; } Certainly an "interesting" approach to returning and clearing. Stephen

It's a known trick, but javac is not smart enough to not generate an exception table, so the resulting bytecode is equivalent to:

String tmp; try { tmp = nextLine; } catch(Throwable t) { nextLine = null; throw t; } nextLine = null; return tmp;

not something beautiful.

Rémi

On 26 April 2013 22:59, Henry Jen <henry.jen at oracle.com> wrote: Hi,

Please review webrev at http://cr.openjdk.java.net/~henryjen/ccc/8003258.1/webrev/ It adds a method to BufferedReader. public Stream lines() {} A class java.io.UncheckedIOException is also added as a general approach for wrapping up an IOException to be unchecked. Cheers, Henry



More information about the core-libs-dev mailing list