Java String Camel Case to Underscore camelCaseToUnderscore(final String str)

Here you can find the source of camelCaseToUnderscore(final String str)

Description

camel Case To Underscore

License

Open Source License

Declaration

public static String camelCaseToUnderscore(final String str) 

Method Source Code

//package com.java2s;

public class Main {
    public static String camelCaseToUnderscore(final String str) {
        final StringBuilder sb = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (Character.isUpperCase(c)) {
                if (i != 0) {
                    sb.append("_");
                }// w ww.  java2 s .  c o m
                sb.append(Character.toLowerCase(c));
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
}

Related

  1. camelCase2UnderScoreCase(String str)
  2. camelCase2UnderscoreLowercase(String name)
  3. camelCaseToLowerCaseUnderline(String name)
  4. camelCaseToUnderline(String name)
  5. camelCaseToUnderscore(final String camelCaseString)
  6. camelCaseToUnderscore(String camelCase)
  7. camelCaseToUnderscore(String camelCased)
  8. camelCaseToUnderScore(String key)
  9. camelCaseToUnderscored(String camelCaseName)