1 package dolda.jsvc.scgi;
5 public class LimitInputStream extends InputStream {
6 private final InputStream bk;
7 private final long limit;
10 public LimitInputStream(InputStream bk, long limit) {
15 public void close() throws IOException {
19 public int available() throws IOException {
20 int av = bk.available();
23 av = (int)(limit - read);
28 public int read() throws IOException {
39 public int read(byte[] b) throws IOException {
40 return(read(b, 0, b.length));
43 public int read(byte[] b, int off, int len) throws IOException {
47 if(len > limit - read)
48 len = (int)(limit - read);
49 int ret = bk.read(b, off, len);
56 public long skip(long n) throws IOException {
60 long ret = bk.skip(n);