public class StringUtil { /** * 按照标点分隔句子,保留标点 */ public static List<String> splitContentByPunctuation(String content, String sepChars) { List<String> res = new ArrayList<>(); if (StringUtils.isBlank(sepChars)) { res.add(content); return res; } char[] chars = content.toCharArray(); StringBuffer stringBuffer = new StringBuffer(); for (char c : chars) { stringBuffer.append(c); if (sepChars.contains(String.valueOf(c))) { res.add(stringBuffer.toString()); stringBuffer = new StringBuffer(); } } if (stringBuffer.length()!=0) { res.add(stringBuffer.toString()); } return res; } }