以下是源代码: 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 SpellHelper { //将中文转换为英文 public static String getEname(String name) { HanyuPinyinOutputFormat pyFormat = new HanyuPinyinOutputFormat(); pyFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); pyFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); pyFormat.setVCharType(HanyuPinyinVCharType.WITH_V); return PinyinHelper.toHanyuPinyinString(name, pyFormat, ""); } //姓、名的第一个字母需要为大写 public static String getUpEname(String name) { char[] strs = name.toCharArray(); String newname = null; //名字的长度 if (strs.length == 2) { newname = toUpCase(getEname("" + strs[0])) + " " + toUpCase(getEname("" + strs[1])); } else if (strs.length == 3) { newname = toUpCase(getEname("" + strs[0])) + " " + toUpCase(getEname("" + strs[1] + strs[2])); } else if (strs.length == 4) { newname = toUpCase(getEname("" + strs[0] + strs[1])) + " " + toUpCase(getEname("" + strs[2] + strs[3])); } else { newname = toUpCase(getEname(name)); } return newname; } //首字母大写 private static String toUpCase(String str) { StringBuffer newstr = new StringBuffer(); newstr.append((str.substring(0, 1)).toUpperCase()).append( str.substring(1, str.length())); return newstr.toString(); } public static void main(String[] args) { System.out.println(getUpEname("李宇春")); } } http://www.javadt.com 【青岛Java课程培训】【青岛大学生就业培训】【青岛大学生实训】 【青岛软件实训课程】【青岛Android培训课程】 真实项目实战:从公司接项目 通过真实项目实战,完成多个大型项目的开发,精通全套JavaEE/ASP.NET技术,掌握分析、设计、开发基于多层架构大型软件系统的原理、方法、技术和过程,将技术完全应用到实践中,毕业即已经拥有了至少1-2年项目开发经验,为职场竞争更添筹码 授课方式:快乐学习+案例驱动授课法 授课以精心设置的案例引领学员学习知识点及技术的应用,在不断的解决问题中享受学习的快乐。通过多个项目来学习掌握计算机编程技术,同时积累至少1-2年的软件软件开发经验;学习过程中每天需要完成软件实训内容;每学完一个专题就配有一个项目实战:学习C的过程中完成图书管理系统系统,学完ASP完成新闻发布系统,学完JavaEE完成电子商务交易平台和在线考试系统, 学完ASP.NET完成办公自动化OA系统或者校园关系网。人手一机,边讲边练,学员累计完成20000~30000行程序,积累1-2年软件开发经验。