拼音工具類

2021-09-26 20:18:41 字數 1420 閱讀 5790

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;

@suppresswarnings("restriction")

public class spellhelper

//將中文轉換為英文

@suppresswarnings()

public static string getename(string name) throws exception

//將中文轉換為英文

@suppresswarnings()

public static string getbeginname(string name) throws exception

//姓、名的第乙個字母需要為大寫

public static string getupename(string name) else if (strs.length == 3) else if (strs.length == 4) else

newname =sb.tostring();//toupcase(getename(name));

}} catch (exception e)

return newname; }

//姓、名的第乙個字母需要為大寫

public static string getspaname(string name) else if (strs.length == 3) else if (strs.length == 4) else

newname =sb.tostring();//toupcase(getename(name));

}} catch (exception e)

return newname;

} //首字母大寫

private static string toupcase(string str)

//獲取首字母

public static string getbeginename(string name)

} catch (exception e)

return newname;

} public static void main(string args) throws exception

}

拼音工具類PinyinUtils

arraymapsurnames new arraymap 35 surnames.put 樂 yue surnames.put 乘 sheng surnames.put 乜 nie surnames.put 仇 qiu surnames.put 會 gui surnames.put 便 pian ...

漢字轉拼音工具類

public class pinyin4jutils 將字串轉換成拼音陣列 param src return public static string stringtopinyin string src,string separator 將字串轉換成拼音陣列 param src param ispo...

漢字轉拼音工具類

package com.example.demo.utils import net.sourceforge.pinyin4j.pinyinhelper author suyanlong date created in 2020 6 30 14 18 description ceshi version...