Class PathTools
Utility methods to facilitate paths and arguments handling.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringFormats a collection of command-line arguments into a single string suitable for logging and safe copy/paste into a POSIX-compatible shell.static StringReturns an empty classpath string.static StringjoinClasspath(@Nullable File @Nullable ... files) Joins multiple files into a single classpath string using the system's path separator.static StringjoinClasspath(@Nullable String @Nullable ... paths) Joins string paths into a single classpath by concatenating non-blank paths using the system's path separator.static StringjoinClasspath(@Nullable Path @Nullable ... paths) Joins multiple paths into a single classpath string using the system's path separator.static StringjoinClasspath(@Nullable Collection<@Nullable Path> paths) Joins a collection of paths into a single classpath string using the system's path separator.static StringjoinClasspath(@Nullable Collection<File> @Nullable ... files) Joins multiple collections of files into a single classpath string using the system's path separator.
-
Method Details
-
formatCommandLine
Formats a collection of command-line arguments into a single string suitable for logging and safe copy/paste into a POSIX-compatible shell.- Parameters:
args- the collection of command-line arguments to format; may benullor empty, and may containnullor empty elements, which are rendered as''- Returns:
- a space-separated string with arguments quoted and escaped for POSIX shells;
an empty string if the collection is
nullor empty - Since:
- 1.0
-
joinClasspath
Returns an empty classpath string. This overload exists to disambiguate zero-argument calls between the variousjoinClasspathvarargs overloads.- Returns:
- an empty string
- Since:
- 1.0
-
joinClasspath
Joins multiple collections of files into a single classpath string using the system's path separator.Each file's normalized absolute path from all provided collections is included in the resulting classpath string.
nullcollections andnullindividual file elements are silently ignored.Uses
Path.toAbsolutePath()followed byPath.normalize()to resolve relative paths and eliminate redundant..and.segments.- Parameters:
files- variable number ofCollections ofFileobjects representing the files to include in the classpath; may benull, andnullcollections or elements are skipped- Returns:
- a classpath string where the normalized absolute paths of all provided files are joined by the system's path separator; an empty string if no valid files are provided
- Since:
- 1.0
-
joinClasspath
Joins multiple files into a single classpath string using the system's path separator.Each file's normalized absolute path is included in the resulting classpath string.
nullindividual file elements are silently ignored.Uses
Path.toAbsolutePath()followed byPath.normalize()to resolve relative paths and eliminate redundant..and.segments.- Parameters:
files- variable number ofFileobjects representing the files to include in the classpath; may benull, andnullelements are skipped- Returns:
- a classpath string where the normalized absolute paths of all provided files are joined by the system's path separator; an empty string if no valid files are provided
- Since:
- 1.0
-
joinClasspath
Joins string paths into a single classpath by concatenating non-blank paths using the system's path separator.Blank or
nullpaths are ignored.- Parameters:
paths- an array of strings representing individual classpath entries; may benull, and individualnullor blank strings are silently skipped- Returns:
- a string representing the concatenated classpath entries, separated by the system's path separator; an empty string if no valid paths are provided
- Since:
- 1.0
-
joinClasspath
Joins a collection of paths into a single classpath string using the system's path separator.Each path's normalized absolute path from the provided collection is included in the resulting classpath string.
nullindividual path elements are silently ignored.Uses
Path.toAbsolutePath()followed byPath.normalize()to resolve relative paths and eliminate redundant..and.segments.- Parameters:
paths- aCollectionofPathobjects representing the paths to include in the classpath; may benull, andnullelements are skipped- Returns:
- a classpath string where the normalized absolute paths of all provided
paths are joined by the system's path separator; an empty string if the collection
is
nullor contains no valid paths - Since:
- 1.0
-
joinClasspath
Joins multiple paths into a single classpath string using the system's path separator.Each path's normalized absolute path is included in the resulting classpath string.
nullindividual path elements are silently ignored.Uses
Path.toAbsolutePath()followed byPath.normalize()to resolve relative paths and eliminate redundant..and.segments.- Parameters:
paths- variable number ofPathobjects representing the paths to include in the classpath; may benull, andnullelements are skipped- Returns:
- a classpath string where the normalized absolute paths of all provided paths are joined by the system's path separator; an empty string if no valid paths are provided
- Since:
- 1.0
-