    public static int countOccurrences(String str, String sub) {
	int len = sub.length();
	int count = 0;
	int pos = str.indexOf(sub);
	while (pos != -1) {
	    count++;
	    pos = str.indexOf(sub, pos + len + 1);
	}
	return count;
    }
