Here you can find the source of toSentenceCase(String original)
public static String toSentenceCase(String original)
//package com.java2s; //License from project: Apache License public class Main { public static String toSentenceCase(String original) { String[] lines = original.split("\\."); for (int i = 0; i < lines.length; i++) { lines[i] = toInitialCap(lines[i]); }//from w w w . ja v a2 s . c om return join(lines, "."); } 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(); } }