检测字符串中是否带汉字中文

Posted 阿拉的梦想

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了检测字符串中是否带汉字中文相关的知识,希望对你有一定的参考价值。

检测字符串中是否带汉字中文

    public static void main(String[] args) throws Exception 
        String str = "6546dsfasf--3=的5";
        if (str.getBytes().length == str.length()) 
            System.out.println("不带汉字");
         else 
            System.out.println("带汉字");
        
    

以上是关于检测字符串中是否带汉字中文的主要内容,如果未能解决你的问题,请参考以下文章