code: int indexOf(byte[] data, int dataLength, byte[] pattern, int dataOffset) {
          int[] failure = computeFailure(pattern);
          int j = 0;
          if (data.length == 0)
              return -1;
          //final int dataLength = data.length;
          final int patternLength = pattern.length;
          for (int i = dataOffset; i < dataLength; i++) {
              while (j > 0 && pattern[j] != data[i])
                  j = failure[j - 1];
              if (pattern[j] == data[i])
                  j++;
              if (j == patternLength)
                  return i - patternLength + 1;
          }
          return -1;
      }
docs: Finds the first occurrence of the pattern in the text.