本文实例讲述了Java实现的汉语拼音工具类。分享给大家供大家参考,具体如下:
10年的播州网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。营销型网站建设的优势是能够根据用户设备显示端的尺寸不同,自动调整播州建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联公司从事“播州网站设计”,“播州网站推广”以来,每个客户项目都认真落实执行。
package test;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
/**
* 汉语拼音工具类
* Created by charlin on 2017/9/3.
*/
public class PingYinUtil {
/**
* 获得所有拼音字母
* @param args
* @return
*/
public static String getAllLeter(String args) {
String result = "";
char[] charArray = args.toCharArray();
String[] strArr = new String[charArray.length];
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
format.setVCharType(HanyuPinyinVCharType.WITH_V);
int len = charArray.length;
for (int i = 0; i 运行结果:

PS:这里再为大家提供几款本站拼音与字母相关工具供大家参考:
在线中英文根据首字母排序工具:
http://tools.jb51.net/aideddesign/zh_paixu
在线汉字转换成拼音工具:
http://tools.jb51.net/transcoding/pinyin
在线中文汉字转拼音工具:
http://tools.jb51.net/transcoding/hanzi2pinyin
在线中文汉字拼音对照转换工具:
http://tools.jb51.net/transcoding/zh_pinyin
在线字母大小写转换工具:
http://tools.jb51.net/transcoding/upper
附:本例中使用到的net.sourceforge.pinyin4j包可点击此处本站下载pinyin4j的jar包文件。
关于eclipse导入jar包的方法可参考本站https://www.jb51.net/softjc/552873.html
更多关于java相关内容感兴趣的读者可查看本站专题:《Java数组操作技巧总结》、《Java字符与字符串操作技巧总结》、《Java数学运算技巧总结》、《Java数据结构与算法教程》及《Java操作DOM节点技巧总结》
希望本文所述对大家java程序设计有所帮助。