汉字转拼音
程序员文章站
2022-07-15 14:50:14
...
通过 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
上一篇: Java虚拟机的选项