List of utility methods to do String Capitalize Word
String | capitalizeWords(String data) Capitalizes each word in the given text by converting the first letter to upper case. if (data == null) return null; StringBuilder res = new StringBuilder(); char ch; char prevCh = '.'; for (int i = 0; i < data.length(); i++) { ch = data.charAt(i); if (Character.isLetter(ch)) { ... |
String | capitalizeWords(String s) capitalizeWords. if (s == null) { return null; String[] tokens = s.split(" "); StringBuilder buf = new StringBuilder(); for (String x : tokens) { buf.append(capitalize(x) + " "); return buf.substring(0, buf.length() - 1); |
String | capitalizeWords(String str) Capitalizes the first letter of every "word" in a string. (Based on ucwords() function of PHP) char[] charArray = str.toCharArray(); String result = ""; charArray[0] = Character.toUpperCase(charArray[0]); for (int i = 0; i < charArray.length; i++) { if (Character.isWhitespace(charArray[i])) charArray[i + 1] = Character.toUpperCase(charArray[i + 1]); result += Character.toString(charArray[i]); return result; |
String | capitalizeWords(String str) Capitalizes all the whitespace separated words in a String. return capitalizeWords(str, null);
|
String | capitalizeWords(String str) (Based on ucwords() function of PHP) DrHouse: still functional but must be rewritten to avoid += to concat strings if ((str == null) || str.isEmpty()) { return str; final char[] charArray = str.toCharArray(); final StringBuilder result = new StringBuilder(); charArray[0] = Character.toUpperCase(charArray[0]); for (int i = 0; i < charArray.length; i++) { if (Character.isWhitespace(charArray[i])) { ... |
String | capitalizeWords(String string) capitalize Words StringBuilder result = new StringBuilder(string.toLowerCase()); for (int i = 0; i < result.length(); i++) { if (i == 0 || !Character.isLetter(result.charAt(i - 1))) { result.setCharAt(i, Character.toUpperCase(result.charAt(i))); return result.toString(); |