通过 pinyin4j 实现
jar包在下面
里面有api
public static void main(String[] args) {
// TODO Auto-generated method stub
String hanyu="大家好";
HanyuPinyinOutputFormat outputFormat = new HanyuPinyinOutputFormat();
outputFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
outputFormat.setVCharType(HanyuPinyinVCharType.WITH_V);
for(char hanyuchar:hanyu.toCharArray()){
try {
System.out.print(PinyinHelper.toHanyuPinyinStringArray(hanyuchar,outputFormat)[0]);
} catch (BadHanyuPinyinOutputFormatCombination e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
jar包在下面
里面有api