Java String Split splitSentence(String sentence)

Here you can find the source of splitSentence(String sentence)

Description

split Sentence

License

Open Source License

Declaration

private static List<String> splitSentence(String sentence) 

Method Source Code


//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;
    }
}

Related

  1. splitScriptToQueries(String script)
  2. SplitSearchTerms(String strSearch)
  3. splitSelection(String selection)
  4. splitSelectionAsInteger(String selection)
  5. splitSemicolonString(String semicolonString)
  6. splitSimple(String split, String s)
  7. splitSimpleQueries(String queryString)
  8. splitSQL(List list, String sql)
  9. splitSQLColumns(String sql)