public static int countOccurrences(String text, String value) { int i = 0; if ((text != null) && (value != null)) {
//int previous = 0; int current = text.indexOf(value); while (current > -1) {
i++;
current += value.length();
//previous = current;
current = text.indexOf(value, current);
}
} return i;
}