Here you can find the source of toCamelCase(String string)
Parameter | Description |
---|---|
string | the string to be camelcased. |
public static String toCamelCase(String string)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w ww . j a v a 2 s . co m*/ * Converts the string to camelcase. Strings are of the format: THIS_IS_A_STRING, and the result of camel casing * would be thisIsAString. * * @param string the string to be camelcased. * @return the camel cased string. * @since 2.0 */ public static String toCamelCase(String string) { StringBuffer result = new StringBuffer(string); while (result.indexOf("_") != -1) { //$NON-NLS-1$ int indexOf = result.indexOf("_"); //$NON-NLS-1$ result.replace(indexOf, indexOf + 2, "" + Character.toUpperCase(result.charAt(indexOf + 1))); //$NON-NLS-1$ } return result.toString(); } }