code: public static String directory(String file) {
        if (StringUtils.isNullOrBlank(file)) {
           return StringUtils.EMPTY;
        }
        file = StringUtils.trim(file);
        int separator = indexOfLastSeparator(file);
        int extension = indexOfFileExtension(file);
  
        if (extension == -1) {
           return addTrailingSlashIfNeeded(file);
        } else if (separator == -1) {
           return StringUtils.EMPTY;
        }
  
        return directory(file.substring(0, separator + 1));
     }
docs: <p>Attempts to get the directory for a given file. Will return itself if the passed in file is a directory. Will
  always return a trailing slash.</p>
  
  @param file The file
  @return The path of the file spec or null if it is null