Here you can find the source of toTitleCase(String givenString)
public static String toTitleCase(String givenString)
//package com.java2s; //License from project: Open Source License public class Main { public static String toTitleCase(String givenString) { if (givenString.length() > 0) { String[] arr = givenString.split(" "); StringBuffer sb = new StringBuffer(); for (int i = 0; i < arr.length; i++) { sb.append(Character.toUpperCase(arr[i].charAt(0))) .append(arr[i].substring(1).toLowerCase()) .append(" "); }/*from w w w . j a v a 2 s . c o m*/ return sb.toString().trim(); } return givenString; } }