Package com.aspectran.utils
Class PathUtils
java.lang.Object
com.aspectran.utils.PathUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
applyRelativePath
(String path, String relativePath) Apply the given relative path to the given Java resource path, assuming standard Java folder separation (i.e.static String
Normalize the path by suppressing sequences like "path/.." and inner simple dots.static boolean
pathEquals
(String path1, String path2) Compare two paths after normalization of them.
-
Field Details
-
REGULAR_FILE_SEPARATOR
- See Also:
-
REGULAR_FILE_SEPARATOR_CHAR
public static final char REGULAR_FILE_SEPARATOR_CHAR- See Also:
-
WINDOWS_FILE_SEPARATOR
- See Also:
-
-
Constructor Details
-
PathUtils
public PathUtils()
-
-
Method Details
-
applyRelativePath
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
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
Compare two paths after normalization of them.- Parameters:
path1
- first path for comparisonpath2
- second path for comparison- Returns:
- whether the two paths are equivalent after normalization
-