@SuppressWarnings("resource") @Test public void testRead_WithLimit100() throws IOException { LimitedInputStream stream = new LimitedInputStream(new ForeverInputStream(), 100); Assert.assertEquals(100, stream.read(new byte[1000])); Assert.assertEquals(-1, stream.read()); }
@Override public int read() throws IOException { if (read(ONE_BYTE, 0, 1) == 1) { return ONE_BYTE[0]; } return -1; }
LimitedInputStream extends FilterInputStream { @Override public int read() throws IOException { if (read(ONE_BYTE, 0, 1) == 1) { return ONE_BYTE[0]; } return -1; } }
LimitedInputStream extends FilterInputStream { @Override public int read() throws IOException { if (read(ONE_BYTE, 0, 1) == 1) { return ONE_BYTE[0]; } return -1; } LimitedInputStream(InputStream in, long numToRead); }
LimitedInputStream extends FilterInputStream { @Override public int read() throws IOException { if (read(ONE_BYTE, 0, 1) == 1) { return ONE_BYTE[0]; } return -1; } LimitedInputStream(InputStream in, long numToRead); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); }
LimitedInputStream extends FilterInputStream { @Override public int read() throws IOException { if (read(ONE_BYTE, 0, 1) == 1) { return ONE_BYTE[0]; } return -1; } LimitedInputStream(InputStream in, long numToRead); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len);  }