@Test public void testRead() throws Exception { final int size = 5; final TestNullReader reader = new TestNullReader(size); for (int i = 0; i < size; i++) { assertEquals("Check Value [" + i + "]", i, reader.read()); } assertEquals("End of File", -1, reader.read()); try { final int result = reader.read(); fail("Should have thrown an IOException, value=[" + result + "]"); } catch (final IOException e) { assertEquals("Read after end of file", e.getMessage()); } reader.close(); assertEquals("Available after close", 0, reader.getPosition()); }
@Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); }
NullReader extends Reader { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); } }
NullReader extends Reader { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); } NullReader(final long size);  NullReader(final long size, final boolean markSupported, final boolean throwEofException); }
NullReader extends Reader { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); } NullReader(final long size);  NullReader(final long size, final boolean markSupported, final boolean throwEofException); long getPosition(); long getSize(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] chars); @Override int read(final char[] chars, final int offset, final int length); @Override synchronized void reset(); @Override long skip(final long numberOfChars); }
NullReader extends Reader { @Override public int read() throws IOException { if (eof) { throw new IOException("Read after end of file"); } if (position == size) { return doEndOfFile(); } position++; return processChar(); } NullReader(final long size);  NullReader(final long size, final boolean markSupported, final boolean throwEofException); long getPosition(); long getSize(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override int read(); @Override int read(final char[] chars); @Override int read(final char[] chars, final int offset, final int length); @Override synchronized void reset(); @Override long skip(final long numberOfChars);  }