code: public static int checkDirectoryArray(final String[] names) {
      int count = 0;
      for (int i = 0; i < names.length; i++) {
        if (names[i] != null) {
          final File dir = new File(names[i]);
          if (dir.exists() && dir.isDirectory()) {
            count++;
          } else {
            names[i] = null;
          }
        }
      }
      return count;
    }
docs: Checks a array of names for non existent or non directory entries and
  nulls them out.
  
  @return Count of non-null elements