is String have Chinese character - Java Internationalization

Java examples for Internationalization:Chinese

Description

is String have Chinese character

Demo Code

public class Main {
  public static void main(String[] argv) {
    String str = "java2s.com";
    System.out.println(is_chinese_char(str));
  }/* w  w w  .  ja v a2 s  .  c  o m*/

  public static boolean is_chinese_char(String str) {
    char c;
    if (isNull(str))
      return false;
    for (int i = 0; i < str.length(); i++) {
      c = str.charAt(i);
      if (!((c <= '9' && c >= '0') || (c <= 'z' && c >= 'a') || (c <= 'Z' && c >= 'A') || c == '_'
          || (c >= '\u4E00' && c <= '\u9FA5'))) {
        return false;
      }
    }
    return true;
  }

  public static boolean isNull(String str) {
    if (str == null || str.length() == 0) {
      return true;
    }
    return false;
  }
}

Related Tutorials