Android examples for java.lang:String Case
capitalize Each Word by locale
public class Main{ public static String capitalizeEachWord(final String text, final String separators, final Locale locale) { final StringBuilder builder = new StringBuilder(); boolean needCapsNext = true; final int len = text.length(); for (int i = 0; i < len; i = text.offsetByCodePoints(i, 1)) { final String nextChar = text.substring(i, text.offsetByCodePoints(i, 1)); if (needCapsNext) { builder.append(nextChar.toUpperCase(locale)); } else { builder.append(nextChar.toLowerCase(locale)); }/* w ww . j a va 2s.c o m*/ // We need a capital letter next if this is a separator. needCapsNext = (-1 != separators.indexOf(nextChar .codePointAt(0))); } return builder.toString(); } }