Here you can find the source of capitalize(String s, String fullstring)
public static String capitalize(String s, String fullstring)
//package com.java2s; //License from project: Open Source License public class Main { public static String capitalize(String s, String fullstring) { s = s.trim();//from w ww. j a v a 2 s .co m if (fullstring == null || fullstring.isEmpty()) { fullstring = s; } if (fullstring.length() < 3) { return s.toUpperCase(); } if (s.contains(" ")) { StringBuilder ret = new StringBuilder(); for (String a : s.split(" ")) { ret.append(" ").append(capitalize(a, s)); } return ret.toString(); } else { if (s.contains(".")) { StringBuilder t = new StringBuilder(); for (String b : s.split("\\.")) { t.append(".").append(capitalize(b, s)); } return t.substring(1); } else { return Character.toUpperCase(s.charAt(0)) + s.substring(1).toLowerCase(); } } } }