Here you can find the source of camel2underline(String s)
public static String camel2underline(String s)
//package com.java2s; //License from project: Apache License public class Main { public static String camel2underline(String s) { char c;/*w ww . j a va2 s .c o m*/ int upperSize = 0; for (int i = 0; i < s.length(); i++) { c = s.charAt(i); if (Character.isUpperCase(c)) { upperSize++; } } if (upperSize == 0) { return s; } StringBuilder buf = new StringBuilder(s.length() + upperSize); for (int i = 0; i < s.length(); i++) { c = s.charAt(i); if (Character.isUpperCase(c)) { buf.append('_'); buf.append(Character.toLowerCase(c)); } else { buf.append(c); } } return buf.toString(); } }