标签:rar ons lower 转换 ret cas == length 大写
将a_boy 转换为 ABoy
public static String firstLetterUpper(String str){ char[] ch = str.toCharArray(); if (ch[0] >= ‘a‘ && ch[0] <= ‘z‘) { ch[0] = (char)(ch[0] - 32); } return new String(ch); } /** * org.apche.commons.lang.StringUtils * 将a_boy 转换为 ABoy * @param str * @return */ public static String firstUpperCamelCase(String str){ if (StringUtils.isNotBlank(str)) { str = str.toLowerCase(); String[] strs = str.split("_"); if (strs.length == 1) { return firstLetterUpper(str); }else { String convertedStr = ""; for (int i = 0; i < strs.length; i++) { convertedStr += firstLetterUpper(strs[i]); } return convertedStr; } } }
标签:rar ons lower 转换 ret cas == length 大写
原文地址:https://www.cnblogs.com/Night-Watch/p/12675093.html