当前位置:   article > 正文

java判断邮箱地址是否正确,使用hutool工具判断邮箱地址是否正确_java 合法email hutools

java 合法email hutools

1.导入hutool的maven依赖

 <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.8.16</version>
        </dependency>
  • 1
  • 2
  • 3
  • 4
  • 5

2.直接复制一下代码运行


import cn.hutool.core.lang.Validator;
public class Test {
    public static void main(String[] args) throws Exception{

        String email = "1234@qq.com";
        String email2 = "1234@qq";
        if (Validator.isEmail(email)) {
            System.out.println(email+"邮箱地址正确");
        }else {
            System.out.println(email+"邮箱地址有误");
        }

        if (Validator.isEmail(email2)) {
            System.out.println(email+"邮箱地址正确");
        }else {
            System.out.println(email2+"邮箱地址有误");
        }

    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/928284
推荐阅读
相关标签
  

闽ICP备14008679号