这两种都是小写转大写,都是进行scii偏移编码的方式,大写转小写同理
/**
* 将字符串的首字母转大写
*
* @param str 需要转换的字符串
* @return
*/
private static String captureName(String str) {
// 进行字母的ascii编码前移
char[] cs = str.toCharArray();
cs[0] -= 32;//大写转小写只需要改为: cs[0] += 32;即可。
return String.valueOf(cs);
}
// 把一个字符串的第一个字母大写
private static String getMethodName(String fildeName) throws Exception {
byte[] items = fildeName.getBytes();
items[0] = (byte) ((char) items[0] - 'a' + 'A');//大写转小写只需要改为:'A' + 'a'即可。
return new String(items);
}