public void readHeader() throws IOException {

    byte[] empty = "".getBytes();
    inflater.setOutput(empty, 0, 0);
    inflater.setInput(empty, 0, 0, false);

    byte[] b = new byte[10];

    int n = fill(b);
    if(n!=10){
      if(n>0){
        inflater.setInput(b, 0, n, false);
        //inflater.next_in_index = n;
        inflater.next_in_index = 0;
        inflater.avail_in = n;
      }
      throw new IOException("no input");
    }

    inflater.setInput(b, 0, n, false);

    byte[] b1 = new byte[1];
    do{
      if(inflater.avail_in<=0){
        int i = in.read(b1);
        if(i<=0)
          throw new IOException("no input");
        inflater.setInput(b1, 0, 1, true);
      }

      int err = inflater.inflate(JZlib.Z_NO_FLUSH);

      if(err!=0/*Z_OK*/){
        int len = 2048-inflater.next_in.length;
        if(len>0){
          byte[] tmp = new byte[len];
          n = fill(tmp);
          if(n>0){
            inflater.avail_in += inflater.next_in_index;
            inflater.next_in_index = 0;
            inflater.setInput(tmp, 0, n, true);
          }
        }
        //inflater.next_in_index = inflater.next_in.length;
        inflater.avail_in += inflater.next_in_index;
        inflater.next_in_index = 0;
        throw new IOException(inflater.msg);
      }
    }
    while(inflater.istate.inParsingHeader());
  }