Java String Capitalize capitalizeString(String toCapitalize)

Here you can find the source of capitalizeString(String toCapitalize)

Description

capitalize String

License

Open Source License

Declaration

public static String capitalizeString(String toCapitalize) 

Method Source Code

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

public class Main {
    public static String capitalizeString(String toCapitalize) {
        if (notEmpty(toCapitalize)) {
            StringBuffer returnBuffer = new StringBuffer();
            char firstChar = toCapitalize.charAt(0);
            returnBuffer.append(("" + firstChar).toUpperCase());
            for (int i = 1; i < toCapitalize.length(); i++) {
                returnBuffer.append(("" + toCapitalize.charAt(i)).toLowerCase());
            }//from   w w  w. j  a  va2 s .  co  m
            return returnBuffer.toString();
        } else {
            return "";
        }
    }

    public static boolean notEmpty(String str) {
        return str != null && !str.trim().equals("");
    }
}

Related

  1. capitalizeString(String str)
  2. capitalizeString(String string)
  3. capitalizeString(String string)
  4. capitalizeString(String string)
  5. capitalizeString(String text, boolean replaceUnderscore)
  6. capitalizeToUpper(String line)
  7. toCapitalized(Object obj)