Java String Split by Line splitIntoNonEmptyLines(String s)

Here you can find the source of splitIntoNonEmptyLines(String s)

Description

split Into Non Empty Lines

License

Open Source License

Declaration

public static ArrayList<String> splitIntoNonEmptyLines(String s) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

public class Main {
    public static ArrayList<String> splitIntoNonEmptyLines(String s) {
        return removeEmptyLines(s.split("\n"));
    }/*ww  w.  j  a v a 2 s. c  o  m*/

    public static ArrayList<String> removeEmptyLines(String lines[]) {
        ArrayList<String> result = new ArrayList<String>();
        for (int i = 0; i < lines.length; i++) {
            if (!lines[i].trim().isEmpty()) {
                result.add(lines[i]);
            }
        }
        return result;
    }
}

Related

  1. splitCommandLine(String str, boolean extract)
  2. splitCommaSeparated(String line)
  3. splitHiddenNewLine(String s)
  4. splitInt(String line, String seperator, int def)
  5. splitIntoLines(String str)
  6. splitIntoNonEmptyLinesWithoutNetLogoComments( String s)
  7. splitLine(final String line, final char delimiter, final char qualifier, final int initialSize)
  8. splitLine(String input, int splitPosition)
  9. SplitLine(String p_line, String p_delimiter)