Here you can find the source of camelhumpToUnderline(String str)
public static String camelhumpToUnderline(String str)
//package com.java2s; /*// www.jav a 2 s . c o m * Copyright (c) 2016 yunmle.com(????????). * * Licensed under the Apache License, Version 2.0 (the "License"); */ public class Main { public static String camelhumpToUnderline(String str) { final int size; final char[] chars; final StringBuilder sb = new StringBuilder((size = (chars = str.toCharArray()).length) * 3 / 2 + 1); char c; for (int i = 0; i < size; i++) { c = chars[i]; if (isLowercaseAlpha(c)) { sb.append(toUpperAscii(c)); } else { sb.append('_').append(c); } } return sb.charAt(0) == '_' ? sb.substring(1) : sb.toString(); } public static boolean isLowercaseAlpha(char c) { return (c >= 'a') && (c <= 'z'); } public static char toUpperAscii(char c) { if (isLowercaseAlpha(c)) { c -= (char) 0x20; } return c; } }