protected void fill() throws IOException {
    if (closed) { throw new IOException("Stream closed"); }
    int len = in.read(buf, 0, buf.length);
    if (len == -1) {
      if(inflater.istate.wrap == 0 &&
         !inflater.finished()){
        buf[0]=0;
        len=1;
      }
      else if(inflater.istate.was != -1){  // in reading trailer
        throw new IOException("footer is not found");
      }
      else{
        throw new EOFException("Unexpected end of ZLIB input stream");
      }
    }
    inflater.setInput(buf, 0, len, true);
  }