Java String Title Case titleCase(String realName)

Here you can find the source of titleCase(String realName)

Description

title Case

License

Open Source License

Declaration

public static String titleCase(String realName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String titleCase(String realName) {
        String space = " ";
        String[] names = realName.split(space);
        StringBuilder b = new StringBuilder();
        for (String name : names) {
            if (name == null || name.isEmpty()) {
                b.append(space);//from www . j  a  v  a 2 s.c  om
                continue;
            }
            b.append(name.substring(0, 1).toUpperCase()).append(name.substring(1).toLowerCase()).append(space);
        }
        return b.toString();
    }
}

Related

  1. titleCase(final String text)
  2. titleCase(String in)
  3. titleCase(String input)
  4. titleCase(String name)
  5. titleCase(String raw)
  6. titleCase(String s)
  7. titleCase(String str)
  8. titlecase(String str)
  9. titleCase(String txt)