Here you can find the source of toCamelCase(String s)
public static String toCamelCase(String s)
//package com.java2s; public class Main { private static final char SEPARATOR = '_'; public static String toCamelCase(String s) { if (s == null) { return null; }//from w ww . jav a 2s. c om s = s.toLowerCase(); StringBuilder sb = new StringBuilder(s.length()); boolean upperCase = false; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == SEPARATOR) { upperCase = true; } else if (upperCase) { sb.append(Character.toUpperCase(c)); upperCase = false; } else { sb.append(c); } } return sb.toString(); } }