首页 » 163邮箱 » 判断是否是汉字

判断是否是汉字

1》//判断是否是汉字

package com.centfor.email.utils;

import org.apache.commons.lang.StringUtils;

/**

* 实用的工具类

* @author zhengwenquan

*

*/

public class AppliedUtils {

//判断是否汉字

public static boolean isChinese(String name) {

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

char chinese = name.charAt(i);

boolean flag = (((chinese <= ‘\u9FB0′) &&(chinese>=’\u4e00′)) || ((chinese<=’\u4DB6′)&&(chinese>=’\u3400’)));

if (!flag){

return false;

}

}

return true;

}

public static void main(String[] args) {

System.out.println(isChinese("华盛顿 "));

System.out.println(StringUtils.trim(" c"));

System.out.println(StringUtils.trim(" c"));

}

}

Comment

You mustlogin In order to post comments.