public static int count(String orig,String find){
  int retVal=0;
  int pos=0;
  while (orig.indexOf(find,pos) > 0) {
    pos=orig.indexOf(find,pos) + 1;
    retVal++;
  }
  return retVal;
}

public static int count ( String orig , String find ) { int retVal = 0 ; int pos = 0 ; while ( orig . indexOf ( find , pos ) > 0 ) { pos = orig . indexOf ( find , pos ) + 1 ; retVal ++ ; } return retVal ; }
should return you the number of occurences of " find " in " orig
