public int getCount(String str, String strToFind)

public int getCount(String str, String strToFind) {
  if (str == null || str.length() == 0) {
   return 0;
  }
  
  if (str.indexOf(strToFind) < 0) {
   return 0;
  }
  
  int totalCount = 0;
  int axisIdx = 0;
  int newIdx = 0;
  
  while ((newIdx = str.indexOf(strToFind, axisIdx)) > -1) {
   totalCount++;
   axisIdx = newIdx + 1;
  }
  
  return totalCount;
 }