@Test public void testCount() { Assert.assertEquals(0, StringUtil.count("test", ";")); Assert.assertEquals(1, StringUtil.count(";", ";")); Assert.assertEquals(4, StringUtil.count(";;;;", ";")); Assert.assertEquals(4, StringUtil.count(";;test;test;", ";")); Assert.assertEquals(4, StringUtil.count(";;;;;;;;;", ";;")); }
public static int count(final String inString, final String substring) { int result = 0; int index = inString.indexOf(substring); while (index != -1) { result++; index = inString.indexOf(substring, index + substring.length()); } return result; }
StringUtil { public static int count(final String inString, final String substring) { int result = 0; int index = inString.indexOf(substring); while (index != -1) { result++; index = inString.indexOf(substring, index + substring.length()); } return result; } }
StringUtil { public static int count(final String inString, final String substring) { int result = 0; int index = inString.indexOf(substring); while (index != -1) { result++; index = inString.indexOf(substring, index + substring.length()); } return result; }  }
StringUtil { public static int count(final String inString, final String substring) { int result = 0; int index = inString.indexOf(substring); while (index != -1) { result++; index = inString.indexOf(substring, index + substring.length()); } return result; }  static String toString(final Vector vect); static Vector toVector(final String string); static String toLowerCamelCase(final String originalString); static String joinStrings(final String[] array, final int start); static String joinStrings(final String[] array, final int start, final int end); static String joinStrings(final String joinString, final String[] array, final int start); static String joinStrings(final String joinString, final String[] array, final int start, final int end); static String joinStrings(final String... strings); static String joinStrings(final String joinString, final String... strings); static String getPossibleSeparator(final List<String> strings, final int size); static String[] splitKeepEmpty(final String string, final String split); static int count(final String inString, final String substring); static String prependLines(final String string, final String prefix); }
StringUtil { public static int count(final String inString, final String substring) { int result = 0; int index = inString.indexOf(substring); while (index != -1) { result++; index = inString.indexOf(substring, index + substring.length()); } return result; }  static String toString(final Vector vect); static Vector toVector(final String string); static String toLowerCamelCase(final String originalString); static String joinStrings(final String[] array, final int start); static String joinStrings(final String[] array, final int start, final int end); static String joinStrings(final String joinString, final String[] array, final int start); static String joinStrings(final String joinString, final String[] array, final int start, final int end); static String joinStrings(final String... strings); static String joinStrings(final String joinString, final String... strings); static String getPossibleSeparator(final List<String> strings, final int size); static String[] splitKeepEmpty(final String string, final String split); static int count(final String inString, final String substring); static String prependLines(final String string, final String prefix);  }