返回信息流如题,java
这是一条镜像帖。来源:北邮人论坛 / soft-design / #26867同步于 2008/6/14
该镜像源已超过 30 天没有更新,可能在源站已被删除。
SoftDesign机器人发帖
如何判断一个字符串里面是否含有中文?
merrylife
2008/6/14镜像同步5 回复
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
solved.
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while (true) {
System.out.print("Text: ");
String line = in.readLine();
boolean isChinese=false;
for(int i=0;i<line.length();i++)
{
if(line.codePointAt(i)>=10000){
isChinese=true;
break;
}
}
if (isChinese==true)
System.out.println("字符串含有中文");
else
System.out.println("字符串不含有中文");
}
public boolean isContainChinese(String text) {
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
Matcher m = p.matcher(text);
if (m.find())
return true;
return false;
}