code: private String extractPathFromUrl(String url) {
          String path = url.replaceAll(".+://.+?(?=/)", "");
          if (!path.startsWith("/")) {
              throw new RuntimeException("Path must start with '/': " + path);
          }
          return path;
      }
docs: Extract directory path from URL, e.g. hdfs://hostname:9000/a/b/c => /a/b/c