标签:blog io java ar sp 2014 on c log
package src;
public class Main {
public static void main(String args[]){
String chinese = "中文 is english";
int clenth = 0;
try{
clenth = chinese.getBytes("gbk").length;
}catch(Exception e){
clenth = chinese.getBytes().length;
}
int clenth1 = chinese.length();
if(clenth==clenth1){
System.out.println("不包含中文");
}else{
System.out.println("包含中文");
}
}
}
结果:包含中文
标签:blog io java ar sp 2014 on c log
原文地址:http://blog.csdn.net/helloboat/article/details/39555271