Here you can find the source of underscoredToCamel(String string)
public static String underscoredToCamel(String string)
//package com.java2s; /*//from w w w . j av a2s. c om Copyright (c) 2009-2011 Olivier Chafik, All Rights Reserved This file is part of JNAerator (http://jnaerator.googlecode.com/). JNAerator is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. JNAerator is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with JNAerator. If not, see <http://www.gnu.org/licenses/>. */ import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static String underscoredToCamel(String string) { String[] a = string.split("_"); for (int i = 0, n = a.length; i < n; i++) { String s = a[i].trim(); a[i] = capitalize(a[i]); } return implode(a, ""); } public static String capitalize(String string) { return string == null ? null : string.length() == 0 ? "" : Character.toUpperCase(string.charAt(0)) + string.substring(1); } public static String capitalize(List<String> strings, String separator) { List<String> cap = new ArrayList<String>(strings.size()); for (String s : strings) cap.add(capitalize(s)); return implode(cap, separator); } public static String implode(double[] array, String separator) { StringBuffer out = new StringBuffer(); boolean first = true; for (double v : array) { if (first) first = false; else out.append(separator); out.append(v); } return out.toString(); } public static String implode(Object[] values) { return implode(values, ", "); } public static String implode(Object[] values, Object separator) { return implode(Arrays.asList(values), separator); } public static final <T> String implode(Iterable<T> elements, Object separator) { String sepStr = separator.toString(); StringBuilder out = new StringBuilder(); boolean first = true; for (Object s : elements) { if (s == null) continue; if (first) first = false; else out.append(sepStr); out.append(s); } return out.toString(); } public static final String implode(Iterable<?> strings) { return implode(strings, ", "); } }