Here you can find the source of capitalize(String str)
public static String capitalize(String str)
//package com.java2s; //License from project: Open Source License public class Main { public static String capitalize(String str) { String[] parts = str.toLowerCase().split(" "); StringBuilder buf = new StringBuilder(); for (String part : parts) { buf.append(part.substring(0, 1).toUpperCase() + part.substring(1) + " "); }/* w ww .ja v a 2s. co m*/ if (buf.length() > 1) { return buf.toString().trim(); } else { return ""; } } }