Here you can find the source of toCamelCase(String s)
public static String toCamelCase(String s)
//package com.java2s; //License from project: Apache License public class Main { public static String toCamelCase(String s) { String[] parts = s.split("_"); //All caps without '_' if (parts.length == 0) { return s.toLowerCase(); }/*from ww w . j av a 2 s . c o m*/ String camelCaseString = ""; for (int i = 0; i < parts.length; i++) { if (i == 0) { camelCaseString = parts[i].toLowerCase(); } else { camelCaseString = camelCaseString + toProperCase(parts[i]); } } return camelCaseString; } public static String toProperCase(String s) { return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); } }