PinyinUtils.java 511 B

123456789101112131415161718192021222324
  1. package com.ydtech.utils;
  2. import com.github.promeg.pinyinhelper.Pinyin;
  3. /**
  4. * Created by zhouhao on 16-6-18.
  5. */
  6. public class PinyinUtils {
  7. /**
  8. * 获取汉字全拼
  9. *
  10. * @param str 汉字字符串
  11. * @return 汉字字符串全拼
  12. */
  13. public static String toPingYin(String str) {
  14. return Pinyin.toPinyin(str, "").toLowerCase();
  15. }
  16. public static void main(String[] args) {
  17. String ping = toPingYin("中国重庆");
  18. System.out.println(ping);
  19. }
  20. }