Java String Camel Case To camelCaseUnderscores(String str)

Here you can find the source of camelCaseUnderscores(String str)

Description

camel Case Underscores

License

Apache License

Declaration

public static String camelCaseUnderscores(String str) 

Method Source Code

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

public class Main {
    public static String camelCaseUnderscores(String str) {
        StringBuffer buff = new StringBuffer();
        boolean capitalize = false;
        boolean doAppend = false;
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if (capitalize) {
                ch = Character.toUpperCase(ch);
                doAppend = true;/* w w  w. ja v a2  s  . com*/
            }
            if (ch == '_') {
                capitalize = true;
                doAppend = false;
            } else {
                capitalize = false;
                doAppend = true;
            }
            if (doAppend) {
                buff.append(ch);
            }

        }
        return buff.toString();
    }
}

Related

  1. camelCaseToSeparatedWords(String ccString, String separator)
  2. camelCaseToSeparatorCase(String s, String separator)
  3. camelCaseToSpacedString(String camel)
  4. camelcaseToUppercase(String camelCase)
  5. camelCaseToWords(String data)
  6. camelHump(String str)
  7. camelHumpsToWords(String camelHumps)
  8. camelhumpToUnderline(String str)
  9. camelizeOneWord(String word, boolean firstLetterInLowerCase)