Package dev.prozilla.pine.common.system
Class PathUtils
java.lang.Object
dev.prozilla.pine.common.system.PathUtils
Utility class for handling path strings.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddLeadingSlash(String path) Adds a leading slash to a path if there isn't one.static StringaddTrailingSlash(String path) Adds a trailing slash to a path if there isn't one.static StringcreateLink(String path) Creates a clickable filepath URL.static StringgetFileExtension(String path) Returns the file extension of a given path.static StringnormalizePath(String path) Normalizes a path by removing prefixes and replacing separators.static StringonlyLeadingSlash(String path) Transforms the path so it has a leading slash and no trailing slash.static StringonlyTrailingSlash(String path) Transforms the path so it has a trailing slash and no leading slash.static StringrelativizePath(String path) Returns a path relative to the source root.static StringremoveLeadingSlash(String path) Removes a leading slash from a path if there is one.static StringremoveTrailingSlash(String path) Removes a trailing slash from a path if there is one.
-
Method Details
-
onlyLeadingSlash
Transforms the path so it has a leading slash and no trailing slash.- Parameters:
path- The original path- Returns:
- The path with only a leading slash.
-
onlyTrailingSlash
Transforms the path so it has a trailing slash and no leading slash.- Parameters:
path- The original path- Returns:
- The path with only a trailing slash.
-
removeLeadingSlash
Removes a leading slash from a path if there is one.- Parameters:
path- The original path- Returns:
- Path without leading slash
-
addLeadingSlash
Adds a leading slash to a path if there isn't one.- Parameters:
path- The original path- Returns:
- Path with leading slash
-
removeTrailingSlash
Removes a trailing slash from a path if there is one.- Parameters:
path- The original path- Returns:
- Path without trailing slash
-
addTrailingSlash
Adds a trailing slash to a path if there isn't one.- Parameters:
path- The original path- Returns:
- Path with trailing slash
-
normalizePath
Normalizes a path by removing prefixes and replacing separators.- Parameters:
path- The original path- Returns:
- The normalized path
-
relativizePath
Returns a path relative to the source root.- Parameters:
path- The original path- Returns:
- The path relative to the source root
-
createLink
Creates a clickable filepath URL.- Parameters:
path- The path of the file or folder- Returns:
- A link to the file or folder
-
getFileExtension
Returns the file extension of a given path.- Parameters:
path- The path of a file- Returns:
- The file extension, or an empty string if
pathisnullor there is no file extension.
-