### Question:
ExactSizeInputStream extends FilterInputStream { @Override public long skip(final long n) throws IOException { final long result = super.skip(Math.min(n, remaining)); if (result > 0) { remaining -= result; } else if (remaining > 0) { throw new EOFException( "Premature EOF. Expected " + remaining + "more bytes"); } return result; } ExactSizeInputStream(InputStream in, int numBytes); @Override int available(); @Override int read(); @Override int read(final byte[] b, final int off, int len); @Override long skip(final long n); @Override boolean markSupported(); @Override void mark(int readlimit);  }### Answer:
@Test public void testSkipNotEnough() throws IOException { ExactSizeInputStream s = new ExactSizeInputStream(byteStream("he"), 5); assertEquals(2, s.skip(3)); try { s.skip(1); fail("Skip when should be out of data"); } catch (EOFException e) { } }