369_是否包含中文字符

来源:互联网 发布:为什么打开软件会闪退 编辑:程序博客网 时间:2024/04/29 05:17




是否包含中文字符


    public static boolean haveChinese(String str){
        try {


            if(str.length() <= 0){
                return false;
            }


            byte [] bytes = str.getBytes("UTF-8");
            if(bytes.length == str.length()){
                return false;
            }else{
                return true;
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return false;
    }

0 0
原创粉丝点击