public boolean checkfilename(String s){ s=new String(s.getBytes());//用GBK编码 String pattern="[\u4e00-\u9fa5]+"; Pattern p=Pattern.compile(pattern); Matcher result=p.matcher(s); return result.find(); //是否含有中文字符 } 注:如果return result.matches()的话,则匹配的是全部为中文,即"^[\u4e00-\u9fa5]+$"; |