RecordReader extends Reader { @Override public int read() throws IOException { if (this.isBufferEmpty()) { this.fillBuffer(); } return this.buffer[pos++]; } RecordReader(Reader in); @Override int read(); @Override int read(char[] cbuf, int off, int len); @Override long skip(final long n); @Override void close();  }
@Test public void testRead() throws IOException { RecordReader reader = new RecordReader(new StringReader("abc\n")); try { assertEquals('a', reader.read()); assertEquals('b', reader.read()); assertEquals('c', reader.read()); for (int i = 3; i < 256; i++) { assertEquals(i + ". character", ' ', reader.read()); } assertEquals('\n', reader.read()); } finally { reader.close(); } }