Java String Underscore to underScore2CamelCase(String strs)

Here you can find the source of underScore2CamelCase(String strs)

Description

under Score Camel Case

License

Apache License

Declaration

public static String underScore2CamelCase(String strs) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String underScore2CamelCase(String strs) {

        if (strs == null || !strs.contains("_")) {
            return strs;
        }//from w  w  w.  j  a  v  a  2s  . c om
        StringBuilder sb = new StringBuilder("");
        String[] elems = strs.split("_");
        for (int i = 0; i < elems.length; i++) {
            String elem = elems[i].toLowerCase();
            if (i != 0) {
                char first = elem.toCharArray()[0];
                sb.append((char) (first - 32)).append(elem.substring(1));
            } else {
                sb.append(elem);
            }
        }
        return sb.toString();
    }
}

Related

  1. underscore2camel(String underscoreName)
  2. underscoreDashToCamelCase(String s)
  3. underscoresToCamelCaseImpl(String input, boolean capNextLetter)
  4. underscoresToSpaces(String value)
  5. underscoreToCamel(String input, boolean firstLetterUppercase)