public static int findRange(ByteBuffer buffer,int start,byte[] pattern){
  byte firstByte=pattern[0];
  int limit=buffer.limit() - pattern.length;
  for (int i=start; i < limit; ++i) {
    if ((firstByte == buffer.get(i)) && matchesRange(buffer,i,pattern)) {
      return i;
    }
  }
  return -1;
}

public static int findRange ( ByteBuffer buffer , int start , byte [ ] pattern ) { byte firstByte = pattern [ 0 ] ; int limit = buffer . limit ( ) - pattern . length ; for ( int i = start ; i < limit ; ++ i ) { if ( ( firstByte == buffer . get ( i ) ) && matchesRange ( buffer , i , pattern ) ) { return i ; } } return - 1 ; }
searches for a pattern of bytes in the given buffer starting at the given offset .
