public class FilePathValidator extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isDescendant(FilePath child,
FilePath parent)
Checks whether a given child path is a descendant of a given parent path using
File.getCanonicalFile(). |
public static boolean isDescendant(FilePath child, FilePath parent) throws IOException
File.getCanonicalFile().
If the child path does not exist, this method will canonicalize path elements such as /../ and
/./ before comparing it to the parent path, and it will not throw an exception. If the child path
does exist, symlinks will be resolved before checking whether the child is a descendant of the parent path.child - FilePathparent - FilePathIllegalStateException - when child or parent FilePath represent remote fileIOException - when File.getCanonicalFile() throwsCopyright © 2016–2022. All rights reserved.