List of utility methods to do String Title Case
String | toTitleCase(String givenString) to Title Case if (givenString.length() > 0) { String[] arr = givenString.split(" "); StringBuffer sb = new StringBuffer(); for (int i = 0; i < arr.length; i++) { sb.append(Character.toUpperCase(arr[i].charAt(0))).append(arr[i].substring(1).toLowerCase()) .append(" "); return sb.toString().trim(); ... |
String | toTitleCase(String input) to Title Case StringBuilder titleCase = new StringBuilder(); boolean nextTitleCase = true; for (char c : input.toCharArray()) { if (Character.isSpaceChar(c)) { nextTitleCase = true; } else if (nextTitleCase) { c = Character.toTitleCase(c); nextTitleCase = false; ... |
String | toTitleCase(String input, boolean eachWord) to Title Case StringBuilder titleCase = new StringBuilder(); boolean nextTitleCase = true; for (char c : input.toCharArray()) { if (Character.isSpaceChar(c) && eachWord) { nextTitleCase = true; } else if (nextTitleCase) { c = Character.toTitleCase(c); nextTitleCase = false; ... |
String | toTitleCase(String inputStr) to Title Case char[] chars = inputStr.trim().toLowerCase().toCharArray(); boolean found = false; for (int i = 0; i < chars.length; i++) { if (!found && Character.isLetter(chars[i])) { chars[i] = Character.toUpperCase(chars[i]); found = true; } else if (Character.isWhitespace(chars[i])) { found = false; ... |
String | toTitleCase(String name) Changes the each first letter of a word to upper case and rest of the strings to lower case if (name == null) { return null; String result = name.substring(0, 1).toUpperCase(); for (int i = 1; i < name.length(); i++) { if (name.substring(i - 1, i).contains(" ") && (name.length() > i + 4) && !name.substring(i, i + 4).equalsIgnoreCase("and ")) result = result + name.substring(i, i + 1).toUpperCase(); ... |
String | toTitleCase(String original) to Title Case String[] words = original.split(" "); for (int i = 0; i < words.length; i++) { words[i] = toInitialCap(words[i]); return join(words, " "); |
String | toTitleCase(String original) to Title Case if (original == null) return null; return Character.toTitleCase(original.charAt(0)) + original.substring(1); |
String | toTitleCase(String s) to Title Case StringBuffer stringbuffer = new StringBuffer(); for (int i = 0; i < s.length(); i++) stringbuffer.append(toTitleCase(s.charAt(i))); return stringbuffer.toString(); |
String | toTitleCase(String s) to Title Case s = s.toLowerCase(); int strl = s.length(); char[] holder = new char[strl]; boolean titleActive = true; int i = 0; while (i < strl) { char nextC = s.charAt(i); if (titleActive == true || i == 0) { ... |
String | toTitleCase(String sIn) to Title Case StringBuffer sb = new StringBuffer(); boolean bFirst = true; for (int i = 0; i < sIn.length(); i++) { char cNext = sIn.charAt(i); if (bFirst) cNext = Character.toUpperCase(cNext); else cNext = Character.toLowerCase(cNext); ... |