Android examples for java.lang:Character
capitalize String via Character static methods
import android.text.Html; import android.text.Spanned; public class Main{ public static String capitalizeString(String string) { char[] chars = string.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;//from w ww.j a va 2 s.co m } else if (Character.isWhitespace(chars[i]) || chars[i] == '.' || chars[i] == '\'') { found = false; } } return String.valueOf(chars); } }