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 String
addLeadingSlash
(String path) Adds a leading slash to a path if there isn't one.static String
addTrailingSlash
(String path) Adds a trailing slash to a path if there isn't one.static String
createLink
(String path) Creates a clickable filepath URL.static String
getFileExtension
(String path) Returns the file extension of a given path.static String
normalizePath
(String path) Normalizes a path by removing prefixes and replacing separators.static String
onlyLeadingSlash
(String path) Transforms the path so it has a leading slash and no trailing slash.static String
onlyTrailingSlash
(String path) Transforms the path so it has a trailing slash and no leading slash.static String
relativizePath
(String path) Returns a path relative to the source root.static String
removeLeadingSlash
(String path) Removes a leading slash from a path if there is one.static String
removeTrailingSlash
(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
path
isnull
or there is no file extension.
-