Java String Camel Case to Underscore camelToUnderline(String param)

Here you can find the source of camelToUnderline(String param)

Description

camel To Underline

License

Open Source License

Declaration

public static String camelToUnderline(String param) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static String camelToUnderline(String param) {
        if (param == null || param.length() == 0) {
            return param;
        }// w ww.  j  av a  2  s  . co m
        int len = param.length();
        StringBuilder sb = new StringBuilder(len);
        for (int i = 0; i < len; i++) {
            char c = param.charAt(i);
            if (Character.isUpperCase(c)) {
                sb.append('_');
                sb.append(Character.toLowerCase(c));
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
}

Related

  1. camelCaseToUnderScore(String key)
  2. camelCaseToUnderscored(String camelCaseName)
  3. camelCaseToUnderscores(String camel)
  4. camelCaseToUnderScoreUpperCase(String camelCase)
  5. camelToUnder(String value)
  6. camelToUnderlinedName(String name)
  7. camelToUnderLineString(String str)
  8. camelToUnderscore(String value)