分字

===========方案一====================

/**
* 拆分成单个字
*/
public static List<String> splitWord(String str) {
  if(str == null || "".equals(str.trim())) {
    return null;
  }
  List<String> listStr = new ArrayList<String>();
  for (int i = 0; i < str.length(); ++i) {
    listStr.add(Character.toString(str.charAt(i)));
  }
  return listStr;
}

===========方案二=====================

public class PatternTest {

public static void main(String[] args) {

String s = new String("我是中国人");

System.out.println(checkChinese(s));

}

public static String checkChinese(String str){

String sb = new String();

Pattern pattern = Pattern.compile("[u3007u4E00-u9FCBuE815-uE864]");//只匹配一个中文字符

Matcher matcher = pattern.matcher(str);

while(matcher.find()){

sb += matcher.group()+";";

}

return sb.toString();

}

}

原文地址:https://www.cnblogs.com/dcxmaozi/p/6679596.html