Android examples for java.lang:String Case
to Camel Case by separator
import android.text.TextUtils; import java.util.Arrays; import java.util.List; public class Main{ public static String toCamelCase(String str, String... separators) { if (separators.length == 0) { separators = new String[] { " ", "_", "-", "," }; }/*ww w . j a va 2s . co m*/ String separatorsRegex = "\\".concat(TextUtils.join("|\\", separators)); String[] splits = str.toLowerCase().split(separatorsRegex); StringBuffer sb = new StringBuffer(); for (String token : splits) { sb.append(token.substring(0, 1).toUpperCase() + token.substring(1)); } return sb.toString(); } }