cdm/src/main/java/ucar/unidata/io/KMPMatch.java
public int indexOf(byte[] data, int start, int max) {
    int j = 0;
    if (data.length == 0) return -1;
    if (start + max > data.length)
      System.out.println("HEY KMPMatch");

    for (int i = start; i < start + max; i++) {
      while (j > 0 && match[j] != data[i])
        j = failure[j - 1];

      if (match[j] == data[i])
        j++;

      if (j == match.length)
        return i - match.length + 1;

    }
    return -1;
  }
public int indexOf(byte[] data, int start, int max) {
    int j = 0;
    if (data.length == 0) return -1;
    if (start + max > data.length)
      System.out.println("HEY KMPMatch");

    for (int i = start; i < start + max; i++) {
      while (j > 0 && match[j] != data[i])
        j = failure[j - 1];

      if (match[j] == data[i])
        j++;

      if (j == match.length)
        return i - match.length + 1;

    }
    return -1;
  }
Finds the first occurrence of match in data.
@param data search in this byte block
@param start start at data[start]
@param max end at data[start+max]
@return index into data[] of first match, else -1 if not found.