int (char @NotNull [] buffer, @NotNull String pattern, int fromIndex) { char[] chars = pattern.toCharArray(); int limit = buffer.length - chars.length + 1; if (fromIndex < 0) { fromIndex = 0; } SearchLoop: for (int i = fromIndex; i < limit; i++) { for (int j = 0; j < chars.length; j++) { if (chars[j] != buffer[i + j]) continue SearchLoop; } return i; } return -1; }