Java String Split by Line splitIntoNonEmptyLinesWithoutNetLogoComments( String s)

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

Description

split Into Non Empty Lines Without Net Logo Comments

License

Open Source License

Declaration

public static ArrayList<String> splitIntoNonEmptyLinesWithoutNetLogoComments(
            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> splitIntoNonEmptyLinesWithoutNetLogoComments(
            String s) {//from ww  w  .j a v a 2  s . co m
        return removeNetLogoCommentsAndEmptyLines(s.split("\n"));
    }

    public static ArrayList<String> removeNetLogoCommentsAndEmptyLines(
            String lines[]) {
        ArrayList<String> result = new ArrayList<String>();
        for (int i = 0; i < lines.length; i++) {
            String line;
            int semicolon = lines[i].indexOf(';');
            if (semicolon < 0) {
                line = lines[i];
            } else {
                line = lines[i].substring(0, semicolon);
            }
            if (!line.trim().isEmpty()) {
                result.add(line);
            }
        }
        return result;
    }
}

Related

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