List of utility methods to do String Capitalize Word
boolean | capitalizedWord(String s) capitalized Word return capitalizedWord(s, 0, s.length());
|
boolean | capitalizedWords(String s) capitalized Words boolean capitalized = true; final int len = s.length(); int wordPos = 0; while (wordPos < len) { final int cp = s.codePointAt(wordPos); if (Character.isUpperCase(cp) || Character.isDigit(cp)) { final int nextWordPos = nextWordPos(s, wordPos); boolean foundLower = false; ... |
String | CapitalizeEachWord(String Str) Capitalize Each Word if (isNullOrEmpty(Str) == true) return null; Str = Str.trim(); boolean first = true; char[] str = Str.toCharArray(); for (int i = 0; i < str.length; ++i) { char c = str[i]; str[i] = (first == true && (i == 0 || i > 0 && str[i - 1] != '\'')) ? Character.toUpperCase(c) ... |
String | capitalizeEachWord(String string) Capitalizes The First Character Of Each Word In The String. if (isNullOrEmpty(string)) return string; StringBuilder stringBuilder = new StringBuilder(); for (String word : string.split(" ")) stringBuilder.append(" ").append(capitalize(word)); stringBuilder.deleteCharAt(0); return stringBuilder.toString(); |
String | capitalizeFirstCharWords(String sentence) Receives a sentence and converts the first letter of each word to a capital letter and the rest of each word to lowercase. final StringBuilder result = new StringBuilder(sentence.length()); String[] words = sentence.split("\\s"); for (int i = 0, length = words.length; i < length; ++i) { if (i > 0) { result.append(" "); result.append(Character.toUpperCase(words[i].charAt(0))).append(words[i].substring(1).toLowerCase()); return result.toString(); |
String | capitalizeFirstLetter(final String word) Capitalizes the first letter of the passed in string. if (isEmpty(word)) return word; if (Character.isUpperCase(word.charAt(0))) return word; if (word.length() == 1) return word.toUpperCase(); return Character.toUpperCase(word.charAt(0)) + word.substring(1); |
String | capitalizeFirstLetter(String word) capitalize First Letter if (word == null || word.isEmpty() || !Character.isLowerCase(word.charAt(0))) return word; return Character.toUpperCase(word.charAt(0)) + word.substring(1); |
String | capitalizeFirstLetterEachWord(String sentence) Capitalize the first letter of each word in a series of words separated by a space character. if (sentence == null) { return null; if (sentence.isEmpty()) { return sentence; sentence = sentence.trim(); if (sentence.length() == 1) { ... |
String | capitalizeFirstLetterWord(String word) Capitalize only the first letter of a given string. if (word == null) { return null; if (word.isEmpty()) { return word; if (word.length() == 1) { return word.toUpperCase(); ... |
String | capitalizeFirsts(String word) capitalize Firsts StringBuffer newWord = new StringBuffer(); boolean shouldCapitalize = true; if (word != null) { for (int i = 0; i < word.length(); i++) { if (Character.isLetter(word.charAt(i)) && shouldCapitalize) { newWord.append(Character.toUpperCase(word.charAt(i))); shouldCapitalize = false; } else if (!Character.isLetter(word.charAt(i))) { ... |