Here you can find the source of toTitleCase(String inputStr)
public static String toTitleCase(String inputStr)
//package com.java2s; /*/*ww w. jav a2 s . co m*/ * Copyright 2006-2007 Vision Tech Solutions,(pvt) Ltd. All Rights Reserved. * This software is the confidential and proprietary information of * Vision Tech Solutions. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Vision Tech Solutions. */ public class Main { public static String toTitleCase(String inputStr) { char[] chars = inputStr.trim().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; } else if (Character.isWhitespace(chars[i])) { found = false; } } return String.valueOf(chars); } }