@Test public void testcountSubStr() { String str = "鬼谷子是春秋战国著名的思想家、鬼谷子是道家、鬼谷子谋略家，鬼谷子称得上是先秦最神秘的历史人物"; assertEquals(4, StringUtil.countSubStr(str, "鬼谷子")); }
public static int countSubStr(String string, String str) { if ((str == null) || (str.length() == 0) || (string == null) || (string.length() == 0)) { return 0; } int count = 0; int index = 0; while ((index = string.indexOf(str, index)) != -1) { count++; index += str.length(); } return count; }
StringUtil { public static int countSubStr(String string, String str) { if ((str == null) || (str.length() == 0) || (string == null) || (string.length() == 0)) { return 0; } int count = 0; int index = 0; while ((index = string.indexOf(str, index)) != -1) { count++; index += str.length(); } return count; } }
StringUtil { public static int countSubStr(String string, String str) { if ((str == null) || (str.length() == 0) || (string == null) || (string.length() == 0)) { return 0; } int count = 0; int index = 0; while ((index = string.indexOf(str, index)) != -1) { count++; index += str.length(); } return count; }  }
StringUtil { public static int countSubStr(String string, String str) { if ((str == null) || (str.length() == 0) || (string == null) || (string.length() == 0)) { return 0; } int count = 0; int index = 0; while ((index = string.indexOf(str, index)) != -1) { count++; index += str.length(); } return count; }  static boolean isEmpty(String str); static String joinString(List list, String symbol); static boolean requals(String str1, String str2); static boolean requals(String str1, String str2, String split); static String subStringOmit(String subject, int size); static String subStringSymbol(String str, int len, String symbol); static String joinString(String[] array, String symbol); static String join(String linkStr, String... strs); static String getHideEmailPrefix(String email); static String repeat(String src, int num); static String ltrim(String str1, int num); static String rtrim(String str, int num); static List<String> parseString2List(String src, String pattern); static String formatDouble(double f, String format); static String left(String input, int count); static String right(String input, int count); static String full2Half(String str); static String Half2Full(String str); static String replaceBlank(String str); static boolean isIn(String substring, String[] source); static String string2Unicode(String string); static String unicode2String(String unicode); static String trimPunct(String str); static double SimilarityRatio(String str1, String str2); static double SimilarDegree(String str1, String str2); static int countSubStr(String string, String str); static String replaceFirst(String s, String sub, String with); static String replaceLast(String s, String sub, String with); static String remove(String s, String sub); static String upperFirstChar(String str); static String lowerFirstChar(String str); static boolean rigthEquals(String str1, String str2, int length); static boolean leftEquals(String str1, String str2, int length); }
StringUtil { public static int countSubStr(String string, String str) { if ((str == null) || (str.length() == 0) || (string == null) || (string.length() == 0)) { return 0; } int count = 0; int index = 0; while ((index = string.indexOf(str, index)) != -1) { count++; index += str.length(); } return count; }  static boolean isEmpty(String str); static String joinString(List list, String symbol); static boolean requals(String str1, String str2); static boolean requals(String str1, String str2, String split); static String subStringOmit(String subject, int size); static String subStringSymbol(String str, int len, String symbol); static String joinString(String[] array, String symbol); static String join(String linkStr, String... strs); static String getHideEmailPrefix(String email); static String repeat(String src, int num); static String ltrim(String str1, int num); static String rtrim(String str, int num); static List<String> parseString2List(String src, String pattern); static String formatDouble(double f, String format); static String left(String input, int count); static String right(String input, int count); static String full2Half(String str); static String Half2Full(String str); static String replaceBlank(String str); static boolean isIn(String substring, String[] source); static String string2Unicode(String string); static String unicode2String(String unicode); static String trimPunct(String str); static double SimilarityRatio(String str1, String str2); static double SimilarDegree(String str1, String str2); static int countSubStr(String string, String str); static String replaceFirst(String s, String sub, String with); static String replaceLast(String s, String sub, String with); static String remove(String s, String sub); static String upperFirstChar(String str); static String lowerFirstChar(String str); static boolean rigthEquals(String str1, String str2, int length); static boolean leftEquals(String str1, String str2, int length);  }