Java Array Empty Check removeEmptyStringsInArray(String[] array)

Here you can find the source of removeEmptyStringsInArray(String[] array)

Description

remove Empty Strings In Array

License

Open Source License

Declaration

public static List<String> removeEmptyStringsInArray(String[] array) 

Method Source Code


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

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

public class Main {
    public static List<String> removeEmptyStringsInArray(String[] array) {
        List<String> list = Arrays.asList(array);
        return removeEmptyStringsInList(list);
    }//from   w w w .  ja v  a 2  s  .c o m

    public static List<String> removeEmptyStringsInList(List<String> list) {
        List<String> newList = new ArrayList<String>();
        for (String s : list) {
            if (!s.isEmpty()) {
                newList.add(s.trim());
            }
        }

        return newList;
    }
}

Related

  1. removeEmptyEntries(String[] array)
  2. removeEmptyLines(String lines[])
  3. removeEmptyString(final String[] words)
  4. removeEmptyString(String[] strOrigin)
  5. removeEmptyStrings(String[] data)
  6. removeNetLogoCommentsAndEmptyLines( String lines[])
  7. removeNullsAndEmptyString(final String[] strArray)
  8. removeTrailingEmptyLines(String[] lines)