使用 jpinyin-1.0.jar
/**
* 繁体转换为简体
* @param str
* @return
*/
public static String convertToSimpli(String str){
String convertToSimplifiedChinese =null;
if(!(null ==str || "".equals(str.trim()))){
convertToSimplifiedChinese = ChineseHelper.convertToSimplifiedChinese(str);
}
return convertToSimplifiedChinese;
}
/**
* 判断字符是否是多音字, 是--true , 不是--false
* @param name
* @return
*/
public static boolean hasMushPinyin(String str ){
char charAt = 0;
if(null == null || "".equals(str.trim())){
charAt = str.charAt(0);
}
boolean flag = PinyinHelper.hasMultiPinyin(charAt);
return flag;
}
/**
* 将首个中文转为拼音的首字母--------例如: 王--->w
* @param name
* @return
*/
public static String converShortPinyin(String str) {
String s = null;
if (!(null == str || "".equals(str.trim()))) {
s = PinyinHelper.getShortPinyin(str);
}
return s;
}