• java中文转拼音


    阅读原文

    废话不多数上代码!

    pinyin4j
    引入maven依赖

    <dependency>
       <groupId>com.belerweb</groupId>
       <artifactId>pinyin4j</artifactId>
       <version>2.5.1</version>
    </dependency>
    
    
    

    实例

    public class Client {
    
      public static void main(String[] args) throws BadHanyuPinyinOutputFormatCombination {
        HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
        //拼音小写
        format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
        //不带声调
        format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
        //要转换的中文,格式,转换之后的拼音的分隔符,遇到不能转换的是否保留   wo,shi,zhong,guo,ren,,hello
        System.out.println(PinyinHelper.toHanYuPinyinString("我是中国人,hello", format, ",", true));
      }
    
    }
    
    
    

    输出结果为

    wo,shi,zhong,guo,ren,,hello
    
  • 相关阅读:
    php1
    c# out参数
    c#冒泡算法
    c#方法 最大值我最小值
    方法
    OUT参数
    芮年
    PHP博客
    数组习题
    从郑和下西洋 到华人爱燕窝
  • 原文地址:https://www.cnblogs.com/userzf/p/16197505.html
Copyright © 2020-2023  润新知