Java Array Empty Check removeTrailingEmptyLines(String[] lines)

Here you can find the source of removeTrailingEmptyLines(String[] lines)

Description

remove Trailing Empty Lines

License

Apache License

Declaration

public static String[] removeTrailingEmptyLines(String[] lines) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static String[] removeTrailingEmptyLines(String[] lines) {
        ArrayList<String> linesList = new ArrayList<String>(Arrays.asList(lines));
        boolean bEndEmptyLine = linesList.get(linesList.size() - 1).equals("");
        while (bEndEmptyLine) {
            linesList.remove(linesList.size() - 1);

            bEndEmptyLine = linesList.get(linesList.size() - 1).equals("");
        }/*from w ww .j  av a  2  s  .co m*/

        String[] newLines = new String[linesList.size()];
        linesList.toArray(newLines);

        return newLines;
    }
}

Related

  1. removeEmptyString(String[] strOrigin)
  2. removeEmptyStrings(String[] data)
  3. removeEmptyStringsInArray(String[] array)
  4. removeNetLogoCommentsAndEmptyLines( String lines[])
  5. removeNullsAndEmptyString(final String[] strArray)