Here you can find the source of capitalizeString(String string)
public static String capitalizeString(String string)
//package com.java2s; public class Main { public static String capitalizeString(String string) { char[] chars = string.toLowerCase().toCharArray(); boolean found = false; for (int i = 0; i < chars.length; i++) { if (!found && Character.isLetter(chars[i])) { chars[i] = Character.toUpperCase(chars[i]); found = true;/*from ww w .ja va2 s . c om*/ } else if (Character.isWhitespace(chars[i]) || chars[i] == '.' || chars[i] == '\'') { // You can add other chars here found = false; } } return String.valueOf(chars); } }