提取字符串中汉字

String tarStr = "I ' m 程序员";

char[] cArr = tarStr .toCharArray();
StringBuffer word = new StringBuffer("");
String s; 
for(char c : cArr){
    s = Character.toString(c);
    if(s.getBytes().length == 2){
        word.append(c);
    }
}
System.out.println(word);

你可能感兴趣的:(提取字符串中汉字)