TextUtils
/** * 计算关键字在文本中出现的次数 * @param text * @param key * @return */ public static int count(String text, String key) { int count = 0, start = 0; while ((start = text.indexOf(key, start)) >= 0) { start += key.length(); count++; } return count; }