static long advancePastNextSyncMarker(PushbackInputStream stream,byte[] syncMarker) throws IOException {
  Seeker seeker=new Seeker(syncMarker);
  byte[] syncBuffer=new byte[syncMarker.length];
  long totalBytesConsumed=0;
  int mark=-1;
  int read;
  do {
    read=stream.read(syncBuffer);
    if (read >= 0) {
      mark=seeker.find(syncBuffer,read);
      totalBytesConsumed+=read;
    }
  }
 while (mark < 0 && read > 0);
  if (mark >= 0) {
    stream.unread(syncBuffer,mark + 1,read - (mark + 1));
    totalBytesConsumed=totalBytesConsumed - (read - (mark + 1));
  }
  return totalBytesConsumed;
}

static long advancePastNextSyncMarker ( PushbackInputStream stream , byte [ ] syncMarker ) throws IOException { Seeker seeker = new Seeker ( syncMarker ) ; byte [ ] syncBuffer = new byte [ syncMarker . length ] ; long totalBytesConsumed = 0 ; int mark = - 1 ; int read ; do { read = stream . read ( syncBuffer ) ; if ( read >= 0 ) { mark = seeker . find ( syncBuffer , read ) ; totalBytesConsumed += read ; } } while ( mark < 0 && read > 0 ) ; if ( mark >= 0 ) { stream . unread ( syncBuffer , mark + 1 , read - ( mark + 1 ) ) ; totalBytesConsumed = totalBytesConsumed - ( read - ( mark + 1 ) ) ; } return totalBytesConsumed ; }
advances to the first byte after the next occurrence of the sync marker in the stream when reading from the current offset . returns the number of bytes consumed from the stream . note that this method requires a pushbackinputstream with a buffer at least as big as the marker it is seeking for .
