code: public static void ensureDirsExistInPath(String path) {
  
      if (path == null || path.length() == 0) {
        throw new AssertionError("ensureDirsExistInPath called with null or empty path.");
      }
  
      String dirPath =
          (path.charAt(path.length() - 1) == File.separatorChar)
              ? path.substring(0, path.length() - 1)
              : (new File(path)).getParent();
      if (dirPath == null || knownExistingDirs.contains(dirPath)) {
        return; // known to exist
      } else {
        (new File(dirPath)).mkdirs();
        knownExistingDirs.add(dirPath);
      }
    }
docs: Ensures that the directories in the given path exist, creating them if necessary.
  
  <p>Note: If the path does not end with the separator char (slash in Linux), then the name at
  the end is assumed to be the file name, so directories are only created down to its parent.
  
  @param path The path for which to ensure directories exist.