public static void kmp(String t, String p) {
        if (t == null || t.length() == 0 || p == null || p.length() == 0) {
            return;
        }
        int next[] = getNext(p);

        int i = 0;
        int j = 0;
        while (i < t.length() && j < p.length()) {
            if (j == -1 || t.charAt(i) == p.charAt(j)) {
                ++i;
                ++j;
            } else {
                j = next[j];
            }
        }
        if (j == p.length()) {
            System.out.println(i - p.length());
            System.out.println(t.substring(i - p.length(), i));
        }
    }