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