字符转换
2021-07-26 本文已影响0人
星钻首席小管家
1.转换驼峰命名
/**
* 转换驼峰命名 如:External English name->externalEnglishName
* @param param
* @return
*/
private String conversionHumpNaming(String param) {
String[] split = param.split("\\s+");
if(split.length==1){
return param;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < split.length; i++) {
char[] ch = split[i].toCharArray();
if(i==0){
if (ch[0] >= 'A' && ch[0] <= 'Z') {
ch[0] = (char) (ch[0] + 32);
}
String strT = new String(ch);
sb.append(strT);
}else {
if (ch[0] >= 'a' && ch[0] <= 'z') {
ch[0] = (char) (ch[0] - 32);
}
String strT = new String(ch);
sb.append(strT);
}
}
return sb.toString().trim();
}