Java String Upper Case toUpperCaseWithUnderscores(String className)

Here you can find the source of toUpperCaseWithUnderscores(String className)

Description

to Upper Case With Underscores

License

Apache License

Declaration

public static String toUpperCaseWithUnderscores(String className) 

Method Source Code

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

public class Main {
    public static String toUpperCaseWithUnderscores(String className) {
        StringBuilder sb = new StringBuilder();
        for (char c : className.toCharArray()) {
            if (c >= 'A' && c <= 'Z' && sb.length() > 0) {
                sb.append('_').append(c);
            } else {
                sb.append(Character.toUpperCase(c));
            }/*from ww  w  .j a  v a 2 s.c  o m*/
        }

        return sb.toString();
    }
}

Related

  1. toUpperCaseNamespace(String string)
  2. toUppercaseNoAccents(String txt)
  3. toUpperCaseNotation(String camelNotation)
  4. toUpperCaseOfFirstChar(String string)
  5. toUpperCaseUnderscore(String text)
  6. toUpperCaseWithUnderscores(String str)