载入天数...载入时分秒...

java通过姓名生成邮箱账号

其中对于四个字单姓的并未处理.
public static void main(String[] args) {
    List<String> names = Stream.of("胡歌","林青霞","林风眠","曹知白","诸葛孔明").collect(Collectors.toList());
    List<String> collect = names.stream()
             .map(PinyinUtil::getPinyin)
             .map(str -> str.split(" "))
             .map(str -> str.length <= 3 ?
                     String.format("%s.%s@xxx.com",   Arrays.stream(str).skip(1).collect(Collectors.joining("")), str[0]) :
                     String.format("%s.%s%s@xxx.com", Arrays.stream(str).skip(2).collect(Collectors.joining("")), str[0], str[1]))
             .collect(Collectors.toList());

    System.out.println(collect);
}
[ge.hu@xxx.com, qingxia.lin@xxx.com, fengmian.lin@xxx.com, zhibai.cao@xxx.com, kongming.zhuge@xxx.com]
posted @ 2022-05-18 00:19  旧信  阅读(180)  评论(0编辑  收藏  举报