jar包:http://pan.baidu.com/s/11ikCY

import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; public class pinyin { public static void main(String[] args) {
System.out.println(new pinyin().Console('你'));
} public String Console(char order) {
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
String[] pinyinArray = null;
try {
pinyinArray = PinyinHelper.toHanyuPinyinStringArray(order, format);
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
} if (pinyinArray!=null) {
return pinyinArray[0];
} else {
return order + "";
}
}
}

利用pingyin4j 将汉字转换为拼音的更多相关文章

  1. JAVA实现汉字转换为拼音 pinyin4j/JPinyin

    在项目中经常会遇到需求用户输入汉字后转换为拼音的场景,比如说通讯录,就会要求按名字首字符发音排序,如果自己写实现这方面的功能是个很好大的工程,还好网上有公开的第三方jar支持转换,结合网上很多前辈的代 ...

  2. iOS将汉字转换为拼音

    将汉字转换为拼音 - (NSString *)chineseToPinyin:(NSString *)chinese withSpace:(BOOL)withSpace { CFStringRef h ...

  3. 使用PinYin4j.jar将汉字转换为拼音

    package com.Test.util; import net.sourceforge.pinyin4j.PinyinHelper; import net.sourceforge.pinyin4j ...

  4. 使用CFStringTransform将汉字转换为拼音

    之前做通讯录相关的一些App时,有一个比较常用的算法是将汉字转换成拼音.当时采用的做法是:将各个拼音段的首个汉字(按Unicode排序)做成两个数组,一个数组存拼音,另一个数组存拼音对应首个汉字的Un ...

  5. sql函数:汉字转换为拼音

    sql数据库自定义一个函数把下面代码写进去 功能是得到汉字拼音首字母create function fun_getPY(@str nvarchar(4000)) returns nvarchar(40 ...

  6. 汉字转换为拼音的JavaScript库

    将JSPinyin剥离mootools这个JavaScript库,可以独立使用. 1)一个是将汉字翻译为拼音,其中每一个字的首字母大写: pinyin.getFullChars(this.value) ...

  7. js汉字转换为拼音

    片段 1 片段 2 gistfile1.txt /* --- description: Pinyin, to get chinese pinyin from chinese. license: MIT ...

  8. C#实现汉字转换为拼音缩写的代码

    using System; using System.Configuration; using System.Data; using System.Web; using System.Web.Secu ...

  9. php将汉字转换为拼音和得到词语首字母(一)

    <?php /** * 修复二分法查找方法 * 汉字拼音首字母工具类 * 注: 英文的字串:不变返回(包括数字) eg .abc123 => abc123 * 中文字符串:返回拼音首字符 ...

随机推荐

  1. poj1860 bellman—ford队列优化 Currency Exchange

    Currency Exchange Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 22123   Accepted: 799 ...

  2. PHP+redis实现超迷你全文检索

    2014年10月31日 11:45:39 情景: 我们平台有好多游戏, 运营的同事在查询某一款游戏的时候, 目前使用的是html的select下拉列表的展现形式, 运营的同事得一个个去找,然后选中,耗 ...

  3. Delphi经验总结(2)

    Q: 怎么来改变ListBox的字体呢?就修改其中的一行. A: 先把ListBox1.Style 设成lbOwnerDrawFixed 然后在 OnDrawItem 事件下写下如下代码 proced ...

  4. XP下使用IIS访问asp出现无权查看网页问题的解决办法

    这是用户权限问题,因为你用的磁盘是NTFS格式. 解决方法: 一.添加用户(“Everyone”或者“IUSR_你的机器名”,如IUSR_HONG,即“Internet 来宾用户”) 二.修改用户权限 ...

  5. sql,联合主键,按id分组求版本号最大值的集合

    表结构如下: /* SQLyog v10.2 MySQL - 5.5.39 ************************************************************** ...

  6. CentOS6.5安装MySql5.5

    最近在CentOS上安装MySql,本来以为yum安装会很简单,但是却花了自己不少时间,所以决定和大家分享下. 首先,安装MySql源! 下载地址:http://dev.mysql.com/downl ...

  7. eclipse 切换svn账号

    1. 查看你的Eclipse中使用的是什么SVN Interface,位置在          windows > preference > Team > SVN 2. 如果是用的J ...

  8. loadingDialog

    1.dialog布局 dialog_loading.xml <?xml version="1.0" encoding="utf-8"?> <L ...

  9. linux下notify机制(仅用于内核模块之间的通信)

    1.通知链表简介 大多数内核子系统都是相互独立的,因此某个子系统可能对其它子系统产生的事件感兴趣.为了满足这个需求,也即是让某个子系统在发生某个事件时通知其它的子系统,Linux内核提供了通知链的机制 ...

  10. SQLServer2008默认服务配置

    SQLServer2008默认服务配置