Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static boolean isChineseByREG(String str) {
        boolean isChinese = true;
        char[] ch = str.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            char c = ch[i];
            if (isChinese(c)) {
            } else {
                isChinese = false;
                break;
            }
        }
        return isChinese;
    }

    public static boolean isChinese(String strName) {

        char[] ch = strName.toCharArray();

        for (int i = 0; i < ch.length; i++) {

            char c = ch[i];

            if (isChinese(c) == true) {

                return isChinese(c);

            } else {

                return isChinese(c);

            }
        }
        return false;
    }

    public static boolean isChinese(char c) {
        // || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION

        // || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION

        Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
        if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS

                || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS

                || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A

                || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {

            return true;

        } else

            return false;

    }
}