Android Japanese String Check isJapanese(String s)

Here you can find the source of isJapanese(String s)

Description

Returns true if the input string is Japanese.

License

Open Source License

Parameter

Parameter Description
s Input

Return

True if Japanese

Declaration

public static boolean isJapanese(String s) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   w w  w  .ja va  2  s. c om*/
     * Returns true if the input string is Japanese.
     * @param s Input
     * @return True if Japanese
     */
    public static boolean isJapanese(String s) {
        if (s == null || s.length() == 0) {
            return false;
        }
        Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(s
                .charAt(0));
        if (unicodeBlock.equals(Character.UnicodeBlock.HIRAGANA)
                || unicodeBlock.equals(Character.UnicodeBlock.KATAKANA)
                || unicodeBlock
                        .equals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS)) {
            return true;
        }
        return false;
    }
}