private void skipStream(Object inputStream,long n) throws IOException, InsufficientDataException {
  RandomAccessFile file=null;
  BufferedInputStream stream=null;
  if (inputStream instanceof RandomAccessFile) {
    file=(RandomAccessFile)inputStream;
  }
 else   if (inputStream instanceof BufferedInputStream) {
    stream=(BufferedInputStream)inputStream;
  }
 else {
    throw new IllegalArgumentException("unsupported input stream object");
  }
  if (file != null) {
    file.seek(file.getFilePointer() + n);
    return;
  }
  long bytesSkipped;
  long totalBytesSkipped=0;
  while ((bytesSkipped=stream.skip(n - totalBytesSkipped)) >= 0) {
    totalBytesSkipped+=bytesSkipped;
    if (totalBytesSkipped == n) {
      return;
    }
  }
  throw new InsufficientDataException("Insufficient data.  bytes skipped " + totalBytesSkipped + " expected "+ n);
}

private void skipStream ( Object inputStream , long n ) throws IOException , InsufficientDataException { RandomAccessFile file = null ; BufferedInputStream stream = null ; if ( inputStream instanceof RandomAccessFile ) { file = ( RandomAccessFile ) inputStream ; } else if ( inputStream instanceof BufferedInputStream ) { stream = ( BufferedInputStream ) inputStream ; } else { throw new IllegalArgumentException ( "unsupported input stream object" ) ; } if ( file != null ) { file . seek ( file . getFilePointer ( ) + n ) ; return ; } long bytesSkipped ; long totalBytesSkipped = 0 ; while ( ( bytesSkipped = stream . skip ( n - totalBytesSkipped ) ) >= 0 ) { totalBytesSkipped += bytesSkipped ; if ( totalBytesSkipped == n ) { return ; } } throw new InsufficientDataException ( "Insufficient data.  bytes skipped " + totalBytesSkipped + " expected " + n ) ; }
skips data of up to given length in given input stream .
