String text = "Working from home takes discipline. If you’re just starting out, it may take you a little time to find your groove, but if you follow the tips above you’ll find it a lot easier. The key is to keep a good work-life balance, establish boundaries, and take care of yourself.";BreakIterator bi = BreakIterator.getSentenceInstance(Locale.ENGLISH); bi.setText(text); for (int start = bi.first(),end=bi.next(); end != BreakIterator.DONE; start = end, end = bi.next()) { System.out.println(text.substring(start,end)); }
按句号截取 就行了吧
bi.setText(text);
for (int start = bi.first(),end=bi.next(); end != BreakIterator.DONE; start = end, end = bi.next()) {
System.out.println(text.substring(start,end));
}