1.导入hutool的maven依赖
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.16</version>
</dependency>
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+"邮箱地址有误");
}
}
}