public static String[] removeNullValues(String[] firstArray) { List<String> list = new ArrayList<String>(); for (String s : firstArray) { if (s != null && s.length() > 0) { list.add(s); } } firstArray = list.toArray(new String[list.size()]); return firstArray; }