Class PathUtils

java.lang.Object
com.aspectran.utils.PathUtils

public abstract class PathUtils extends Object
  • Field Details

  • Constructor Details

    • PathUtils

      public PathUtils()
  • Method Details

    • applyRelativePath

      public static String applyRelativePath(@NonNull String path, String relativePath)
      Apply the given relative path to the given Java resource path, assuming standard Java folder separation (i.e. "/" separators).
      Parameters:
      path - the path to start from (usually a full file path)
      relativePath - the relative path to apply (relative to the full file path above)
      Returns:
      the full file path that results from applying the relative path
    • cleanPath

      public static String cleanPath(String path)
      Normalize the path by suppressing sequences like "path/.." and inner simple dots.

      The result is convenient for path comparison. For other uses, notice that Windows separators ("\") are replaced by simple slashes.

      NOTE that cleanPath should not be depended upon in a security context. Other mechanisms should be used to prevent path-traversal issues.

      Parameters:
      path - the original path
      Returns:
      the normalized path
    • pathEquals

      public static boolean pathEquals(String path1, String path2)
      Compare two paths after normalization of them.
      Parameters:
      path1 - first path for comparison
      path2 - second path for comparison
      Returns:
      whether the two paths are equivalent after normalization