public synchronized long skip(final long n)
    throws IOException
  {
    checkIfStillOpen();
    // Sanity check
    if (n <= 0) {
      return 0;
    }
    // Skip buffered data if there is any
    if (pos < count) {
      int avail = count - pos;
      if (avail > n) {
        pos += n;
        return n;
      }
      else {
        pos = count;
        return avail;
      }
    }
    // Read into buffers and skip
    else {
      fill(); // This is potentially blocking (i.e. the read on the underlying inputStream could be blocking)
      int avail = count - pos;
      if (avail <= 0)
        return 0;
      long skipped = (avail < n) ? avail : n;
      pos += skipped;
      return skipped;
    }
  }