String test="网络部,kkkl;综合";
        System.out.print(test.charAt(3));
        System.out.println( test.charAt( 3 ) > 256 ? "Yes" : "No" );

解决方案 »

  1.   

    //[\u4E00-\u9FA5]是所有汉字集合的正则表达式
    String test="汉字";
    if(test.matches("[\\u4E00-\\u9FA5]+")) System.out.println("contains chinese chars");
      

  2.   

    String str = "ab测试22d";
    for(int i = 0; i < str.length(); i++) {
        char c = str.charAt(i);
        if(c > 255) {
            System.out.println("contains chinese chars!!!");
        }
    }
      

  3.   

    谢谢各们的帮忙,只不过xcopy(xcopy)为什么你的代码我执行不了呀??
      

  4.   

    .match 在jdk1.4后才出现的
    你的jdk版本太老了
    所以没有
    :)
      

  5.   

    正则表达式要jdk1.4以上,版本的可以直接判断char的值
    如果大于等于4e00小于等于9fa5就是汉字,否则不是.
      

  6.   

    要判断不是拉丁字符很简单,楼上的某些都可以,但是要判断是不是中文就不好办了。或许jdk1.4可以做得到吧,我没用过。kadina(次帅) 的做法,对于日语一样输出“包含中文”的字样!
      

  7.   

    好象不行啊。
    不能匹配汉字啊。可以匹配‘=’,代码是:
    import java.io.*;
    import java.util.regex.*;/**
     *  Description of the Class
     *
     *@author     Administrator
     *@created    2003?¨?6??8??
     */
    public final class RegexTestHarness {    private static String REGEX;
        private static String INPUT;
        private static BufferedReader br;
        private static Pattern pattern;
        private static Matcher matcher;
        private static boolean found;
        /**
         *  The main program for the RegexTestHarness class
         *
         *@param  argv  The command line arguments
         */
        public static void main(String[] argv) {
            initResources();
            processTest();
            closeResources();
        }
        /**
         *  Description of the Method
         */
        private static void initResources() {
            try {
                br = new BufferedReader(new FileReader("regex.txt"));
            } catch (FileNotFoundException fnfe) {
                System.out.println("Cannot locate input file! " + fnfe.getMessage());
                System.exit(0);
            }
            try {
                REGEX = br.readLine();
                INPUT = br.readLine();
            } catch (IOException ioe) {}        pattern = Pattern.compile(REGEX);
            matcher = pattern.matcher(INPUT);        System.out.println("Current REGEX is: " + REGEX);
            System.out.println("Current INPUT is: " + INPUT);
        }
        /**
         *  Description of the Method
         */
        private static void processTest() {
            while (matcher.find()) {
                System.out.println("I found the text \"" + matcher.group() +
                        "\" starting at index " + matcher.start() +
                        " and ending at index " + matcher.end() + ".");
                System.out.println(INPUT.substring(matcher.start(), matcher.end()));
                found = true;
            }        if (!found) {
                System.out.println("No match found.");
            }
        }
        /**
         *  Description of the Method
         */
        private static void closeResources() {
            try {
                br.close();
            } catch (IOException ioe) {}
        }
    }