Here you can find the source of removeEmptyStrings(Collection
Remove empty strings from a collection.
Parameter | Description |
---|---|
data | The data. |
public static String[] removeEmptyStrings(Collection<String> data)
//package com.java2s; // The MIT License(MIT) import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { /**//from w w w. j a va 2 s .c o m * <p> * Remove empty strings from a collection. * </p> * * @param data The data. * @return The data with empty entries removed. */ public static String[] removeEmptyStrings(Collection<String> data) { List<String> result = new ArrayList<>(); for (String element : data) { if (element == null || element.isEmpty()) { continue; } result.add(element); } return result.toArray(new String[result.size()]); } }