public class PathUtil
extends java.lang.Object
Utility methods for operations with file path strings. Unlike IO, NIO2 and FileUtil,
these methods are platform-agnostic - i.e. able to work with Windows paths on Unix systems and vice versa.
Both forward- and backward-slashes are legal separators.
Warning: the methods are by definition less strict and in some cases could produce incorrect results.
Unless you're certain you need the relaxed handling, prefer NIO2 instead.
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getParent(java.lang.String path)
Returns a parent path according to the rules applicable to the given path,
or
null when the path is a file system root or unrecognized. |
static boolean |
isAbsolute(java.lang.String path)
Returns
true absolute UNC (even incomplete), DOS and Unix paths; false otherwise. |
public static boolean isAbsolute(java.lang.String path)
true absolute UNC (even incomplete), DOS and Unix paths; false otherwise.applicability warningpublic static java.lang.String getParent(java.lang.String path)
Returns a parent path according to the rules applicable to the given path,
or null when the path is a file system root or unrecognized.
A path should not contain duplicated separators (except at the beginning of a UNC path), otherwise the result could be incorrect.
Directory traversals are not processed (getParent("/a/b/..") returns "/a/b" instead of "/a", etc).
applicability warning