List of utility methods to do String Char Count
int | countChars(String s, String charset) count Chars int nc = 0; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (charset.indexOf(c) >= 0) nc++; return nc; |
int | countChars(String string, char c) Count the number of occurrences of the character in the string. int result = 0; int ppos = string.indexOf(c); while (ppos >= 0) { ++result; ppos = string.indexOf(c, ppos + 1); return result; |
int | countChars(String string, int character) Count number of times specified character appears in string. int count = 0; int currIndex = 0; while (true) { currIndex = string.indexOf(character, currIndex); if (currIndex == -1) break; ++currIndex; ++count; ... |
int | countChars(String text, char ch, int from, int to) Counts number of specified characters in give text. int textLen = text.length(); if (from < 0) { from = 0; if (to >= textLen) { to = textLen - 1; int count = 0; ... |
int | countCharsInString(final String stringToCountOccurrancesIn, final char characterToCount) Count occurrances of a character in a string if (stringToCountOccurrancesIn == null) { throw new IllegalArgumentException("null s"); final char[] chars = stringToCountOccurrancesIn.toCharArray(); int count = 0; for (char c : chars) { if (c == characterToCount) { count++; ... |