List of utility methods to do String Capitalize
String | capitalize(String s) capitalize. if (isEmpty(s)) { return s; return Character.toTitleCase(s.charAt(0)) + s.substring(1); |
String | capitalize(String s) capitalize if (s == null) return new String(); switch (s.length()) { case 0: return new String(); case 1: return s.toUpperCase(); default: ... |
String | capitalize(String s) Capitalizes the first letter (and only the first!) of the string. if (s == null || s.length() == 0) return s; return Character.toUpperCase(s.charAt(0)) + s.substring(1); |
String | capitalize(String s) capitalize char first = s.charAt(0); return Character.isTitleCase(first) ? s : Character.toTitleCase(first) + s.substring(1); |
String | capitalize(String s) Ensures that a string starts with a capitalized letter. if (s == null || s.isEmpty()) return s; char first = s.charAt(0); if (Character.isLetter(first) && Character.isLowerCase(first)) return Character.toUpperCase(first) + s.substring(1); else return s; |
String | capitalize(String s) capitalize String[] split = s.split("_"); String result = ""; for (int i = 0; i < split.length; i++) { if (i != 0) { result += " " + split[i].substring(0, 1).toUpperCase() + split[i].substring(1); } else { result += split[i].substring(0, 1).toUpperCase() + split[i].substring(1); return result; |
String | capitalize(String s) Uppercases the first character of a string. if (Character.isLowerCase(s.charAt(0))) { return Character.toUpperCase(s.charAt(0)) + s.substring(1); } else { return s; |
String | capitalize(String s) Capitalizes the given string, making its first character upper case, and the rest of them lower case. if (isNullOrEmpty(s)) return EMPTY; StringBuilder out = new StringBuilder(s.length()); out.append(Character.toUpperCase(s.charAt(0))); if (s.length() > 1) out.append(s.substring(1).toLowerCase()); return out.toString(); |
String | capitalize(String s) capitalize String result = s; if ((s != null) && (s.length() > 0) && Character.isLowerCase(s.charAt(0))) { char[] chars = s.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); result = new String(chars); return result; |
String | capitalize(String s) capitalize if (s == null) { return null; String[] words = s.split(" "); StringBuffer buffer = new StringBuffer(); for (String word : words) { if (buffer.length() > 0) { buffer.append(' '); ... |