Here you can find the source of capitalizeName(String name)
public static String capitalizeName(String name)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w. j a v a2 s .c om * Capitalizes the first word of the supplied name, preserves the case of * subsequent words and lower cases all other letters. */ public static String capitalizeName(String name) { StringBuilder cname = new StringBuilder(); boolean wasSpace = false; for (int ii = 0, ll = name.length(); ii < ll; ii++) { char c = name.charAt(ii); if (ii == 0) { cname.append(Character.toUpperCase(c)); } else if (wasSpace) { cname.append(c); } else { cname.append(Character.toLowerCase(c)); } wasSpace = Character.isWhitespace(c); } return cname.toString(); } }