ExtendedBufferedReader extends BufferedReader { @Override public String readLine() throws IOException { final String line = super.readLine(); if (line != null) { lastChar = LF; eolCounter++; } else { lastChar = END_OF_STREAM; } return line; } ExtendedBufferedReader(final Reader reader); @Override int read(); @Override int read(final char[] buf, final int offset, final int length); @Override String readLine(); boolean isClosed(); @Override void close();  }
@Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertNull(br.readLine()); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertNull(br.readLine()); br = getBufferedReader("foo\n\nhello"); assertEquals(0, br.getCurrentLineNumber()); assertEquals("foo",br.readLine()); assertEquals(1, br.getCurrentLineNumber()); assertEquals("",br.readLine()); assertEquals(2, br.getCurrentLineNumber()); assertEquals("hello",br.readLine()); assertEquals(3, br.getCurrentLineNumber()); assertNull(br.readLine()); assertEquals(3, br.getCurrentLineNumber()); br = getBufferedReader("foo\n\nhello"); assertEquals('f', br.read()); assertEquals('o', br.lookAhead()); assertEquals("oo",br.readLine()); assertEquals(1, br.getCurrentLineNumber()); assertEquals('\n', br.lookAhead()); assertEquals("",br.readLine()); assertEquals(2, br.getCurrentLineNumber()); assertEquals('h', br.lookAhead()); assertEquals("hello",br.readLine()); assertNull(br.readLine()); assertEquals(3, br.getCurrentLineNumber()); br = getBufferedReader("foo\rbaar\r\nfoo"); assertEquals("foo",br.readLine()); assertEquals('b', br.lookAhead()); assertEquals("baar",br.readLine()); assertEquals('f', br.lookAhead()); assertEquals("foo",br.readLine()); assertNull(br.readLine()); }