Here you can find the source of underscore2camel(String underscoreName)
Parameter | Description |
---|---|
underscoreName | a parameter |
public static String underscore2camel(String underscoreName)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w .j a va 2 s. c o m * convert underscore name to camel name * @param underscoreName * @return */ public static String underscore2camel(String underscoreName) { String[] sections = underscoreName.split("_"); StringBuilder sb = new StringBuilder(); for (int i = 0; i < sections.length; i++) { String s = sections[i]; if (i == 0) { sb.append(s); } else { sb.append(capitalize(s)); } } return sb.toString(); } /** * capitalize the first character * @param str * @return */ public static String capitalize(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return str; } return new StringBuilder(strLen).append(Character.toTitleCase(str.charAt(0))).append(str.substring(1)) .toString(); } }