List of utility methods to do String Capitalize
String | capitalize(String str) Capitalizes a string, i.e. if (str == null || str.length() == 0) return str; else return str.substring(0, 1).toUpperCase() + str.substring(1); |
String | capitalize(String str) Capitalizes the first letter of str. if (str == null) { return null; } else if (str.trim().equals("")) { return str; String result = str.substring(0, 1).toUpperCase() + str.substring(1, str.length()); return result; |
String | capitalize(String str) capitalize char[] chars = str.toCharArray(); boolean sentenceStart = true; for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (sentenceStart) { if (c >= 'a' && c <= 'z') { chars[i] -= 0x20; sentenceStart = false; ... |
String | capitalize(String str) Capitalizes all the whitespace separated words in a String. int strLen; if (str == null || (strLen = str.length()) == 0) { return str; StringBuffer buffer = new StringBuffer(strLen); boolean whitespace = true; for (int i = 0; i < strLen; i++) { char ch = str.charAt(i); ... |
String | capitalize(String str) capitalize if ((null == str) || str.isEmpty()) { return str; final char[] buffer = str.toCharArray(); boolean capitalizeNext = true; for (int i = 0; i < buffer.length; ++i) { final char ch = buffer[i]; if (Character.isWhitespace(ch)) { ... |
String | capitalize(String str) capitalize if (isEmpty(str)) return str; char[] cs = str.toCharArray(); cs[0] = Character.toUpperCase(cs[0]); return new String(cs); |
String | capitalize(String str, char... delimiters) Capitalizes all the delimiter separated words in a String. int delimLen = delimiters == null ? -1 : delimiters.length; char[] buffer = str.toCharArray(); boolean capitalizeNext = true; for (int i = 0; i < buffer.length; i++) { char ch = buffer[i]; if (isDelimiter(ch, delimiters)) { capitalizeNext = true; } else if (capitalizeNext) { ... |
String | capitalize(String str, char[] wordDelimiters) Capitalize first letter of each word. int strLen = str.length(); StringBuffer buffer = new StringBuffer(strLen); boolean capitalizeNext = true; for (int i = 0; i < strLen; i++) { char ch = str.charAt(i); boolean isDelimiter = false; for (int j = 0, isize = wordDelimiters.length; j < isize; j++) { if (ch == wordDelimiters[j]) { ... |
String | capitalize(String str, String delim) capitalize str = str.replaceAll("&", "and"); String[] strings = str.split("[ _]+"); final StringBuilder sb = new StringBuilder(); for (String s : strings) { s = s.toLowerCase(); sb.append(s.substring(0, 1).toUpperCase()); sb.append(s.substring(1)).append(delim); sb.deleteCharAt(sb.length() - 1); return sb.toString(); |
String | capitalize(String str, String delimiter) capitalize String[] parts = str.split("\\s"); StringBuffer res = new StringBuffer(); for (int i = 0, l = parts.length; i < l; i++) { if (i > 0) res.append(delimiter); String part = parts[i]; res.append(Character.toUpperCase(part.charAt(0))); res.append(part, 1, part.length()); ... |