public class PathAndURLUtils
extends java.lang.Object
Constructor and Description |
---|
PathAndURLUtils() |
Modifier and Type | Method and Description |
---|---|
static java.nio.file.Path |
getCommonAncestorDirectory(java.util.Set<java.nio.file.Path> paths)
Returns the most specific common ancestor of the given nonempty set of paths.
|
static java.nio.file.Path |
getRelativeTo(java.nio.file.Path from,
java.nio.file.Path to)
Makes a relative Path that is relative to the 'from' directory.
|
static java.util.Optional<java.nio.file.Path> |
getRelativeToTAJS(java.nio.file.Path to)
Makes a relative Path that is relative to the TAJS directory, if possible.
|
static java.nio.file.Path |
getRelativeToWorkingDirectory(java.nio.file.Path path)
Makes a relative Path that is relative to the working directory.
|
static java.nio.file.Path |
getWorkingDirectory()
Returns the current working directory.
|
static boolean |
isConsumable(java.net.URL url)
Checks if a URL points to something readable.
|
static java.net.URL |
normalizeFileURL(java.net.URL url)
Normalizes a file URL using the underlying path normalization.
|
static void |
reset() |
static java.nio.file.Path |
toPath(java.net.URL url,
boolean normalize)
Converts a URL to a Path.
|
static java.lang.String |
toPortableString(java.nio.file.Path path)
OS-independent toString method for paths.
|
static java.nio.file.Path |
toRealPath(java.nio.file.Path p)
Wrapper for
Path.toRealPath(LinkOption...) that converts IOException to AnalysisException
and caches the result. |
static java.net.URL |
toURL(java.nio.file.Path p)
Converts a Path to a URL.
|
static java.net.URL |
toURL(java.lang.String str)
Converts a string to a URL.
|
public static java.nio.file.Path getCommonAncestorDirectory(java.util.Set<java.nio.file.Path> paths)
AnalysisException
- if one of the files do not exist (or some other error occurred)public static java.nio.file.Path getRelativeTo(java.nio.file.Path from, java.nio.file.Path to)
AnalysisException
- if the file does not exist (or some other error occurred)public static java.util.Optional<java.nio.file.Path> getRelativeToTAJS(java.nio.file.Path to)
AnalysisException
- if the file does not exist (or some other error occurred)public static java.nio.file.Path getRelativeToWorkingDirectory(java.nio.file.Path path)
AnalysisException
- if the file does not exist (or some other error occurred)public static java.nio.file.Path getWorkingDirectory()
public static boolean isConsumable(java.net.URL url)
public static java.net.URL normalizeFileURL(java.net.URL url)
AnalysisException
- if the file does not exist (or some other error occurred)public static void reset()
public static java.nio.file.Path toPath(java.net.URL url, boolean normalize)
normalize
- if set, normalize the path (resolve symlinks)AnalysisException
- if 'normalize' is set and the file does not exist (or some other error occurred)public static java.lang.String toPortableString(java.nio.file.Path path)
public static java.nio.file.Path toRealPath(java.nio.file.Path p)
Path.toRealPath(LinkOption...)
that converts IOException
to AnalysisException
and caches the result.AnalysisException
- if the file does not exist (or some other error occurred)public static java.net.URL toURL(java.nio.file.Path p)
public static java.net.URL toURL(java.lang.String str)
AnalysisException
- if the file does not exist (or some other error occurred)Copyright © 2009-2019 Aarhus University