Here you can find the source of camel2underline(String hump)
public static String camel2underline(String hump)
//package com.java2s; //License from project: Open Source License public class Main { private static final int alphaStep = 'a' - 'A'; public static String camel2underline(String hump) { StringBuilder underline = new StringBuilder(); char[] chars = hump.trim().toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (i == 0) underline.append(toUpperCase(c)); else { if (isUpperCase(c)) { underline.append('_'); underline.append(c); } else underline.append(toUpperCase(c)); }/*from w ww .ja va 2 s. c o m*/ } return underline.toString(); } public static char toUpperCase(char c) { return isLowerCase(c) ? (char) (c - alphaStep) : c; } public static boolean isUpperCase(char c) { return c >= 'A' && c <= 'Z'; } public static boolean isLowerCase(char c) { return c >= 'a' && c <= 'z'; } }