public static int indexOf(@NotNull CharSequence buffer,@NotNull CharSequence pattern,int fromIndex,final int toIndex){
  final int patternLength=pattern.length();
  int limit=toIndex - patternLength + 1;
  if (fromIndex < 0) {
    fromIndex=0;
  }
  SearchLoop:   for (int i=fromIndex; i < limit; i++) {
    for (int j=0; j < patternLength; j++) {
      if (pattern.charAt(j) != buffer.charAt(i + j))       continue SearchLoop;
    }
    return i;
  }
  return -1;
}

public static int indexOf ( @ NotNull CharSequence buffer , @ NotNull CharSequence pattern , int fromIndex , final int toIndex ) { final int patternLength = pattern . length ( ) ; int limit = toIndex - patternLength + 1 ; if ( fromIndex < 0 ) { fromIndex = 0 ; } SearchLoop : for ( int i = fromIndex ; i < limit ; i ++ ) { for ( int j = 0 ; j < patternLength ; j ++ ) { if ( pattern . charAt ( j ) != buffer . charAt ( i + j ) ) continue SearchLoop ; } return i ; } return - 1 ; }
tries to find index of given pattern at the given buffer .
