java获取汉子的拼音
来源:互联网 发布:java数组实现二叉树 编辑:程序博客网 时间:2024/04/28 02:21
今天任务需要,查了许多资料终于找到一个可以获取汉子的拼音的jar吧,官网http://pinyin4j.sourceforge.net我登不上
引用pinyin4j.jar
import java.io.IOException;import java.util.regex.Matcher;import java.util.regex.Pattern;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;public class PinYinHelper {private static HanyuPinyinOutputFormat spellFormat = new HanyuPinyinOutputFormat();// 判断字符串是否包含有中文 public static boolean isChinese(String str) {String regex = "[\\u4e00-\\u9fa5]";Pattern pattern = Pattern.compile(regex);Matcher matcher = pattern.matcher(str);return matcher.find();}public static String chineneToPinyin(String chineseStr) {spellFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE);spellFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);spellFormat.setVCharType(HanyuPinyinVCharType.WITH_V);String pinYin = "";if(isChinese(chineseStr)){pinYin = PinyinHelper.toHanyuPinyinString(chineseStr, spellFormat, "").toUpperCase();}else{pinYin = chineseStr.toUpperCase();}return pinYin;}public static void main(String[] args){System.out.println(chineneToPinyin("我爱中国"));}}
- java获取汉子的拼音
- Java获取汉子拼音
- C#获取汉子对应的拼音
- JAVA汉子和拼音的转化
- Java 汉子转拼音
- java汉子转拼音
- pinyin4j 使用 获取第一个汉子的首字母,获取汉子拼音
- ASP.NET或WinFrom中获取汉子的拼音首字母
- python小点心--获取汉子拼音首字母
- 生成汉子拼音首字母全部的
- java 汉子转换为拼音 简码 及全拼音
- java汉子获取大写首字母
- Java获取汉子区位码
- java获取汉字的拼音
- iOS 汉子转拼音
- 汉子转拼音
- 汉子转化为拼音
- 将汉子转化为拼音的js插件
- silverlight调用vcdll
- Windows 7 C盘下无法新建文件
- SecureCRT 7 序列号
- eclipse中svn插件的安装与使用
- 抽象类(abstract)和接口(interface)的区别
- java获取汉子的拼音
- 英文环境下Emacs使用ibus输入法
- linux chinese input method
- MYSQL 创建表连接(类ORACLE DBLINK但是单表)
- UIView关联多个Gesture
- HQL
- lucene 4.3 通过TokenStream显示分词代码演示
- 绝对路径与相对路径区别
- 'MySqlConnection' is ambiguous in the namespace 'MySql.Data.MySqlClient'