LookaheadInputStream extends InputStream { @Override public int read() throws IOException { fill(); if (buffered > position) { return 0xff & buffer[position++]; } else { return -1; } } LookaheadInputStream(InputStream stream, int n); @Override void close(); @Override int read(); @Override int read(byte[] b, int off, int len); @Override long skip(long n); @Override int available(); @Override boolean markSupported(); @Override synchronized void mark(int readlimit); @Override synchronized void reset();  }
@Test public void testNullStream() throws IOException { InputStream lookahead = new LookaheadInputStream(null, 100); assertEquals(-1, lookahead.read()); }