Here you can find the source of toCamelCase(String string)
public static String toCamelCase(String string)
//package com.java2s; //License from project: Apache License public class Main { public static String toCamelCase(String string) { StringBuilder result = new StringBuilder(); // [#2515] - Keep trailing underscores for (String word : string.split("_", -1)) { // Uppercase first letter of a word if (word.length() > 0) { // [#82] - If a word starts with a digit, prevail the // underscore to prevent naming clashes if (Character.isDigit(word.charAt(0))) { result.append("_"); }/* www. j a v a 2s. c o m*/ result.append(word.substring(0, 1).toUpperCase()); result.append(word.substring(1).toLowerCase()); } else { // If no letter exists, prevail the underscore (e.g. leading // underscores) result.append("_"); } } return result.toString(); } }