Here you can find the source of capitalize(String orig)
static public String capitalize(String orig)
//package com.java2s; //License from project: Open Source License public class Main { static public String capitalize(String orig) { StringBuffer buf = new StringBuffer(orig); for (int i = 0; i < orig.length(); i++) { if (i == 0 || orig.charAt(i - 1) == ' ') { if (Character.isLowerCase(orig.charAt(i))) { buf.setCharAt(i, Character.toUpperCase(orig.charAt(i))); }//from w w w. j a va2s .co m } } String r = new String(buf); return r; } }