Here you can find the source of splitSentence(String sentence)
private static List<String> splitSentence(String sentence)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { private static List<String> splitSentence(String sentence) { List<String> result = new ArrayList(); StringBuilder sb = new StringBuilder(); for (char c : sentence.toCharArray()) { if (c == '\n') { if (sb.length() > 0) { result.add(sb.toString()); sb = new StringBuilder(); }/*from ww w . j a v a2s .c om*/ } else { sb.append(c); } } if (sb.length() > 0) result.add(sb.toString()); return result; } }