public long skip(long n) throws IOException
  {
    long totalSkipped = 0;
    long skipped;

    // loop until bytes are really skipped.
    while (totalSkipped < n)
    {
      skipped = in.skip(n-totalSkipped);

      if (totalSkipped ==-1)
        throw new IOException("skip not supported");
      else if(skipped == 0)
        return 0;
      else
        totalSkipped += totalSkipped + skipped;
    }

    //change the firstRead flag
    if(firstRead)
      firstRead = false;

    return totalSkipped;
  }