List of utility methods to do String Capitalize
String | capitalize(String str) capitalize if (isAlpha(str.charAt(0))) { return str.substring(0, 1).toUpperCase() + str.substring(1); } else return str.charAt(0) + str.substring(1, 2).toUpperCase() + str.substring(2); |
String | capitalize(String str) capitalize String[] parts = str.toLowerCase().split(" "); StringBuilder buf = new StringBuilder(); for (String part : parts) { buf.append(part.substring(0, 1).toUpperCase() + part.substring(1) + " "); if (buf.length() > 1) { return buf.toString().trim(); } else { ... |
String | capitalize(String str) Capitalizes the first character of the given String. if (str == null || str.length() < 1) return str; return str.substring(0, 1).toUpperCase() + str.substring(1); |
String | capitalize(String str) Capitalizes all the whitespace separated words in a String. return capitalize(str, null);
|
String | capitalize(String str) capitalize StringBuilder sb = new StringBuilder(str); String firstChar = sb.substring(0, 1); String upperFirstChar = firstChar.toUpperCase(); sb.delete(0, 1); sb.insert(0, upperFirstChar); return sb.toString(); |
String | capitalize(String str) capitalize if (str == null || str.length() == 0) { return str; StringBuilder sb = new StringBuilder(str.length()); sb.append(Character.toUpperCase(str.charAt(0))); sb.append(str.toLowerCase().substring(1)); return sb.toString(); |
String | capitalize(String str) Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) . int strLen; if (str == null || (strLen = str.length()) == 0) { return str; return new StringBuffer(strLen).append(Character.toTitleCase(str.charAt(0))).append(str.substring(1)) .toString(); |
String | capitalize(String str) capitalize String capitalized = str; if (str == null || str.isEmpty()) { return capitalized; capitalized = String.valueOf(str.charAt(0)).toUpperCase() + str.substring(1); return capitalized; |
String | capitalize(String str) capitalize return changeFirstCharacterCase(str, true);
|
String | capitalize(String str) Capitalize a String , changing the first letter to upper case as per Character#toUpperCase(char) . return changeFirstCharacterCase(str, true);
|