Here you can find the source of capitalizeString(String toCapitalize)
public static String capitalizeString(String toCapitalize)
//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(""); } }