@Test public void readingEmptyByteArrayWithOffsetAndZeroLimitTest() throws IOException { LimitedInputStream stream = new LimitedInputStream(new ByteArrayInputStream(new byte[0]), 0); byte[] bytes = new byte[100]; Assert.assertEquals(-1, stream.read(bytes, 0, 100)); }
@Override public int read() throws IOException { if (isStreamRead) { return -1; } if (isLimitViolated) { throw new ReadingByteLimitException(); } int nextByte = inputStream.read(); readingByteLimit--; checkReadingByteLimit(nextByte); return nextByte; }
LimitedInputStream extends InputStream { @Override public int read() throws IOException { if (isStreamRead) { return -1; } if (isLimitViolated) { throw new ReadingByteLimitException(); } int nextByte = inputStream.read(); readingByteLimit--; checkReadingByteLimit(nextByte); return nextByte; } }
LimitedInputStream extends InputStream { @Override public int read() throws IOException { if (isStreamRead) { return -1; } if (isLimitViolated) { throw new ReadingByteLimitException(); } int nextByte = inputStream.read(); readingByteLimit--; checkReadingByteLimit(nextByte); return nextByte; } LimitedInputStream(InputStream inputStream, long readingByteLimit); }
LimitedInputStream extends InputStream { @Override public int read() throws IOException { if (isStreamRead) { return -1; } if (isLimitViolated) { throw new ReadingByteLimitException(); } int nextByte = inputStream.read(); readingByteLimit--; checkReadingByteLimit(nextByte); return nextByte; } LimitedInputStream(InputStream inputStream, long readingByteLimit); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override void close(); @Override long skip(long n); @Override int available(); @Override synchronized void mark(int readlimit); @Override synchronized void reset(); @Override boolean markSupported(); }
LimitedInputStream extends InputStream { @Override public int read() throws IOException { if (isStreamRead) { return -1; } if (isLimitViolated) { throw new ReadingByteLimitException(); } int nextByte = inputStream.read(); readingByteLimit--; checkReadingByteLimit(nextByte); return nextByte; } LimitedInputStream(InputStream inputStream, long readingByteLimit); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override void close(); @Override long skip(long n); @Override int available(); @Override synchronized void mark(int readlimit); @Override synchronized void reset(); @Override boolean markSupported();  }