private int fill(byte[] buf) {
    int len = buf.length;
    int n = 0;
    do{
      int i = -1;
      try {
        i = in.read(buf, n, buf.length - n);
      }
      catch(IOException e){
      }
      if(i == -1){
        break;
      }
      n+=i;
    }
    while(n<len);
    return n;
  }