Java String Title Case toTitleCase(String input)

Here you can find the source of toTitleCase(String input)

Description

to Title Case

License

Apache License

Declaration

public static String toTitleCase(String input) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String toTitleCase(String input) {
        StringBuilder titleCase = new StringBuilder();
        boolean nextTitleCase = true;

        for (char c : input.toCharArray()) {
            if (Character.isSpaceChar(c)) {
                nextTitleCase = true;/*from   ww w.  j a  va  2  s .c  om*/
            } else if (nextTitleCase) {
                c = Character.toTitleCase(c);
                nextTitleCase = false;
            }

            titleCase.append(c);
        }

        return titleCase.toString();
    }
}

Related

  1. toTitleCase(final String inStr)
  2. toTitleCase(final String inStr, final boolean putRestInLC)
  3. toTitleCase(final String s)
  4. toTitleCase(final String text)
  5. toTitleCase(String givenString)
  6. toTitleCase(String input, boolean eachWord)
  7. toTitleCase(String inputStr)
  8. toTitleCase(String name)
  9. toTitleCase(String original)