1.导入huool工具的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 str1 = "abc123";
String str2 = "abc123你好";
boolean a = Validator.hasChinese(str1);
System.out.println(a?"包含汉字":"不包含汉字");
boolean b = Validator.hasChinese(str2);
System.out.println(b?"包含汉字":"不包含汉字");
}
}