Java Array Empty Check removeEmptyString(String[] strOrigin)

Here you can find the source of removeEmptyString(String[] strOrigin)

Description

Remove empty string elements from origin string array

License

Open Source License

Return

String array

Declaration

public static String[] removeEmptyString(String[] strOrigin) 

Method Source Code


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

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

public class Main {
    /**//from w  ww.jav a  2  s .  c o  m
     * Remove empty string elements from origin string array
     * @return String array
     */
    public static String[] removeEmptyString(String[] strOrigin) {
        List<String> strList = new ArrayList<String>();
        for (String str : strOrigin) {
            if (str != null && !str.trim().isEmpty()) {
                strList.add(str);
            }
        }
        return strList.toArray(new String[0]);
    }
}

Related

  1. removeEmpty(String[] strings)
  2. removeEmptyElements(String[] firstArray)
  3. removeEmptyEntries(String[] array)
  4. removeEmptyLines(String lines[])
  5. removeEmptyString(final String[] words)
  6. removeEmptyStrings(String[] data)
  7. removeEmptyStringsInArray(String[] array)
  8. removeNetLogoCommentsAndEmptyLines( String lines[])
  9. removeNullsAndEmptyString(final String[] strArray)