Java String Capitalize capitalize(CharSequence s)

Here you can find the source of capitalize(CharSequence s)

Description

capitalize

License

Open Source License

Declaration

public static CharSequence capitalize(CharSequence s) 

Method Source Code

//package com.java2s;

public class Main {
    public static CharSequence capitalize(CharSequence s) {
        if (isNotBlank(s) && !Character.isUpperCase(s.charAt(0))) {
            final StringBuilder sb = new StringBuilder(s);
            sb.setCharAt(0, Character.toUpperCase(s.charAt(0)));
            return sb.toString();
        }/*from   w  w  w  .ja v  a  2 s.com*/

        return s;
    }

    public static boolean isNotBlank(final CharSequence s) {
        if (s != null) {
            int len = s.length();
            for (int i = 0; i < len; i++) {
                if (!Character.isWhitespace(s.charAt(i))) {
                    return true;
                }
            }
        }
        return false;
    }
}

Related

  1. capitalised(String name)
  2. capitaliseName(String name)
  3. capitalizar(String s)
  4. capitalizarPalabra(String palabra)
  5. capitalizarTexto(String texto)
  6. capitalize(CharSequence s)
  7. capitalize(final String docName)
  8. capitalize(final String input)
  9. capitalize(final String name)