public int read(byte[] b,int off,int len) throws IOException {
  ensureOpen();
  if (b == null) {
    throw new NullPointerException("Null buffer for read");
  }
 else   if (off < 0 || len < 0 || len > b.length - off) {
    throw new IndexOutOfBoundsException();
  }
 else   if (len == 0) {
    return 0;
  }
  int cnt=0;
  while (len > 0 && !def.finished()) {
    int n;
    if (def.needsInput()) {
      n=in.read(buf,0,buf.length);
      if (n < 0) {
        def.finish();
      }
 else       if (n > 0) {
        def.setInput(buf,0,n);
      }
    }
    n=def.deflate(b,off,len);
    cnt+=n;
    off+=n;
    len-=n;
  }
  if (cnt == 0 && def.finished()) {
    reachEOF=true;
    cnt=-1;
  }
  return cnt;
}

public int read ( byte [ ] b , int off , int len ) throws IOException { ensureOpen ( ) ; if ( b == null ) { throw new NullPointerException ( "Null buffer for read" ) ; } else if ( off < 0 || len < 0 || len > b . length - off ) { throw new IndexOutOfBoundsException ( ) ; } else if ( len == 0 ) { return 0 ; } int cnt = 0 ; while ( len > 0 && ! def . finished ( ) ) { int n ; if ( def . needsInput ( ) ) { n = in . read ( buf , 0 , buf . length ) ; if ( n < 0 ) { def . finish ( ) ; } else if ( n > 0 ) { def . setInput ( buf , 0 , n ) ; } } n = def . deflate ( b , off , len ) ; cnt += n ; off += n ; len -= n ; } if ( cnt == 0 && def . finished ( ) ) { reachEOF = true ; cnt = - 1 ; } return cnt ; }
reads compressed data into a byte array . this method will block until some input can be read and compressed .
