Java Utililty Methods String Title Case

List of utility methods to do String Title Case

Description

The list of methods to do String Title Case are organized into topic(s).

Method

StringtoTitleCase(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();
...
StringtoTitleCase(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;
...
StringtoTitleCase(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;
...
StringtoTitleCase(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;
...
StringtoTitleCase(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();
...
StringtoTitleCase(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, " ");
StringtoTitleCase(String original)
to Title Case
if (original == null)
    return null;
return Character.toTitleCase(original.charAt(0)) + original.substring(1);
StringtoTitleCase(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();
StringtoTitleCase(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) {
...
StringtoTitleCase(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);
...