public static String camelCaseToUnderscored(String camelCaseName){
  int i=0;
  while (i < camelCaseName.length() && Character.isLowerCase(camelCaseName.charAt(i))) {
    i++;
  }
  if (i == camelCaseName.length()) {
    return camelCaseName;
  }
  StringBuilder sb=new StringBuilder();
  sb.append(camelCaseName.substring(0,i));
  while (i < camelCaseName.length()) {
    final char c=camelCaseName.charAt(i);
    if (isUpperUSASCII(c)) {
      sb.append('_');
      sb.append(Character.toLowerCase(c));
    }
 else {
      sb.append(c);
    }
    i++;
  }
  return sb.toString();
}

public static String camelCaseToUnderscored ( String camelCaseName ) { int i = 0 ; while ( i < camelCaseName . length ( ) && Character . isLowerCase ( camelCaseName . charAt ( i ) ) ) { i ++ ; } if ( i == camelCaseName . length ( ) ) { return camelCaseName ; } StringBuilder sb = new StringBuilder ( ) ; sb . append ( camelCaseName . substring ( 0 , i ) ) ; while ( i < camelCaseName . length ( ) ) { final char c = camelCaseName . charAt ( i ) ; if ( isUpperUSASCII ( c ) ) { sb . append ( '_' ) ; sb . append ( Character . toLowerCase ( c ) ) ; } else { sb . append ( c ) ; } i ++ ; } return sb . toString ( ) ; }
a deliberately very inflexible camel case to underscored converter ; it must not convert improper camel case names to a proper underscored name .
