@Test public void countWordsTest() { String test = "Long long long time ago"; long words = CountUtil.countWords(test, LocaleCode.EN.getId()); assertThat(words).isEqualTo(5); }
public static long countWords(@NotNull String content, @NotNull String localeCode) { if (StringUtils.isBlank(content) || StringUtils.isBlank(localeCode)) { return 0; } try { LocaleId locale = getLocaleId(localeCode); Tokens tokens = StringTokenizer.tokenizeString(content, locale, "WORD"); return tokens.size(); } catch (Exception e) { Object[] args = new Object[] { content, localeCode, e }; log.error("unable to count words in string '{}' for locale '{}'", args); return 0; } }
CountUtil { public static long countWords(@NotNull String content, @NotNull String localeCode) { if (StringUtils.isBlank(content) || StringUtils.isBlank(localeCode)) { return 0; } try { LocaleId locale = getLocaleId(localeCode); Tokens tokens = StringTokenizer.tokenizeString(content, locale, "WORD"); return tokens.size(); } catch (Exception e) { Object[] args = new Object[] { content, localeCode, e }; log.error("unable to count words in string '{}' for locale '{}'", args); return 0; } } }
CountUtil { public static long countWords(@NotNull String content, @NotNull String localeCode) { if (StringUtils.isBlank(content) || StringUtils.isBlank(localeCode)) { return 0; } try { LocaleId locale = getLocaleId(localeCode); Tokens tokens = StringTokenizer.tokenizeString(content, locale, "WORD"); return tokens.size(); } catch (Exception e) { Object[] args = new Object[] { content, localeCode, e }; log.error("unable to count words in string '{}' for locale '{}'", args); return 0; } } private  CountUtil(); }
CountUtil { public static long countWords(@NotNull String content, @NotNull String localeCode) { if (StringUtils.isBlank(content) || StringUtils.isBlank(localeCode)) { return 0; } try { LocaleId locale = getLocaleId(localeCode); Tokens tokens = StringTokenizer.tokenizeString(content, locale, "WORD"); return tokens.size(); } catch (Exception e) { Object[] args = new Object[] { content, localeCode, e }; log.error("unable to count words in string '{}' for locale '{}'", args); return 0; } } private  CountUtil(); static long countWords(@NotNull String content,
            @NotNull String localeCode); static long countCharacters(@Nonnull String content); }
CountUtil { public static long countWords(@NotNull String content, @NotNull String localeCode) { if (StringUtils.isBlank(content) || StringUtils.isBlank(localeCode)) { return 0; } try { LocaleId locale = getLocaleId(localeCode); Tokens tokens = StringTokenizer.tokenizeString(content, locale, "WORD"); return tokens.size(); } catch (Exception e) { Object[] args = new Object[] { content, localeCode, e }; log.error("unable to count words in string '{}' for locale '{}'", args); return 0; } } private  CountUtil(); static long countWords(@NotNull String content,
            @NotNull String localeCode); static long countCharacters(@Nonnull String content);  }