Here you can find the source of toUpperCaseWithUnderscores(String className)
public static String toUpperCaseWithUnderscores(String className)
//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(); } }