PushbackLineNumberReader extends PushbackReader { public String readLine() throws IOException { char[] buf = new char[257]; int len = 257; for (int i = 0; i < len; i++) { int ch = this.read(); if ((ch == -1) || (ch == '\n') || (ch == '\r') || (ch == 0)) { len = i; break; } buf[i] = (char) ch; } return new String(buf).substring(0, len); } PushbackLineNumberReader(final Reader in);  PushbackLineNumberReader(final Reader in, final int size); @Override int read(); @Override int read(final char[] cbuf); @Override int read(final CharBuffer target); @Override int read(final char[] cbuf, final int off, final int len); String readLine(); @Override void reset(); @Override void unread(final char[] cbuf, final int off, final int len); @Override void unread(final char[] cbuf); @Override void unread(final int c); int getLineNumber(); void skipNewline(); void skipWhitespace(); void skip(final char... chars); @Override String toString();  }
@Test public void testReadLine() throws IOException { String line = lineNumberReader.readLine(); assertEquals("hello", line); }