Here you can find the source of toTitleCase(String original)
public static String toTitleCase(String original)
//package com.java2s; //License from project: Apache License public class Main { public static String toTitleCase(String original) { String[] words = original.split(" "); for (int i = 0; i < words.length; i++) { words[i] = toInitialCap(words[i]); }// w ww . ja va 2 s .co m return join(words, " "); } public static String toInitialCap(String original) { if (original.trim().length() == 0) return ""; return original.substring(0, 1).toUpperCase() + original.substring(1).toLowerCase(); } public static String join(String[] text, String appendChar) { StringBuffer sentance = new StringBuffer(); for (int i = 0; i < text.length; i++) { sentance.append(text[i]); if (i != text.length - 1) sentance.append(appendChar); } return sentance.toString(); } public static String toString(String[] arrStrs) { StringBuffer strBuf = new StringBuffer(); for (int i = 0; i < arrStrs.length; i++) { strBuf.append(arrStrs[i] + ", "); } return strBuf.toString(); } }