@Override public synchronized int read(byte b[], int off, int len) throws IOException { int canRead = (int)Math.min(getRemainingBytes(), len); if(canRead==0) return handleStreamOutOfBound(); int nbRead = in.read(b, off, canRead); if(nbRead>0) totalRead += nbRead; return nbRead; }
@Override public synchronized int read() throws IOException { if(getRemainingBytes()==0) return handleStreamOutOfBound(); int i = in.read(); totalRead++; return i; }
@Override public synchronized long skip(long n) throws IOException { int canSkip = (int)Math.min(getRemainingBytes(), n); if(canSkip==0) return handleStreamOutOfBound(); long nbSkipped = in.skip(canSkip); if(nbSkipped>0) totalRead += nbSkipped; return nbSkipped; }