StringUtils { public static int countMatches(final String toSearchIn, final char toFind) { return countMatches(toSearchIn, String.valueOf(toFind)); } private  StringUtils(); static String concatElementsSeparatedBy(final Object[] strings, final char separator); static String concatElementsSeparatedBy(final Collection<?> strings, final char separator); static String concatElementsSeparatedByComma(final Collection<?> strings); static String concatElementsSeparatedBy(final Collection<?> strings, final String separator); static String concatElementsSeparatedBy(
        final Collection<?> strings,
        final String separator,
        final boolean excludeEmptyValues); static String concat(final String separator, final Object... objects); static String concat(final String separator, final Iterable<?> objects); static String concat(final String separator, final boolean excludeEmptyValues, final Object... objects); static String concat(final String separator, final boolean excludeEmptyValues, final Iterable<?> objects); static String truncateToLength(final String string, final int length); static int countMatches(final String toSearchIn, final char toFind); static int countMatches(final String toSearchIn, final String toFind); static String loop(final String tanga, final int count);  }
@Test public void testCountMatches() { Assert.assertEquals(0, StringUtils.countMatches(null, null)); Assert.assertEquals(0, StringUtils.countMatches("foo", null)); Assert.assertEquals(0, StringUtils.countMatches(null, "foo")); Assert.assertEquals(1, StringUtils.countMatches("abcdefghijkl", "e")); Assert.assertEquals(4, StringUtils.countMatches("abcdeeefgheijkl", "e")); Assert.assertEquals(7, StringUtils.countMatches("eabcdeeefgheijkele", "e")); Assert.assertEquals(11, StringUtils.countMatches("eeeabcdeeefgheijkeleee", "e")); Assert.assertEquals(1, StringUtils.countMatches("abcdefghijkl", 'e')); Assert.assertEquals(4, StringUtils.countMatches("abcdeeefgheijkl", 'e')); Assert.assertEquals(7, StringUtils.countMatches("eabcdeeefgheijkele", 'e')); Assert.assertEquals(11, StringUtils.countMatches("eeeabcdeeefgheijkeleee", 'e')); Assert.assertEquals(3, StringUtils.countMatches("abbabaabbaa", "ab")); Assert.assertEquals(1, StringUtils.countMatches("abbabaabbaa", "aab")); }