@Stringable @InterfaceAudience.Public @InterfaceStability.Stable public class Path extends Object implements Comparable<Path>, Serializable, ObjectInputValidation
FileSystem.
 Path strings use slash as the directory separator.| Modifier and Type | Field and Description | 
|---|---|
static String | 
CUR_DIR
The current directory, ".". 
 | 
static String | 
SEPARATOR
The directory separator, a slash. 
 | 
static char | 
SEPARATOR_CHAR
The directory separator, a slash, as a character. 
 | 
static boolean | 
WINDOWS
Whether the current host is a Windows machine. 
 | 
| Constructor and Description | 
|---|
Path(Path parent,
    Path child)
Create a new Path based on the child path resolved against the parent path. 
 | 
Path(Path parent,
    String child)
Create a new Path based on the child path resolved against the parent path. 
 | 
Path(String pathString)
Construct a path from a String. 
 | 
Path(String parent,
    Path child)
Create a new Path based on the child path resolved against the parent path. 
 | 
Path(String parent,
    String child)
Create a new Path based on the child path resolved against the parent path. 
 | 
Path(String scheme,
    String authority,
    String path)
Construct a Path from components. 
 | 
Path(URI aUri)
Construct a path from a URI 
 | 
| Modifier and Type | Method and Description | 
|---|---|
int | 
compareTo(Path o)  | 
int | 
depth()
Returns the number of elements in this path. 
 | 
boolean | 
equals(Object o)  | 
FileSystem | 
getFileSystem(Configuration conf)
Return the FileSystem that owns this Path. 
 | 
String | 
getName()
Returns the final component of this path. 
 | 
Path | 
getParent()
Returns the parent of a path or null if at root. 
 | 
static Path | 
getPathWithoutSchemeAndAuthority(Path path)
Return a version of the given Path without the scheme information. 
 | 
int | 
hashCode()  | 
boolean | 
isAbsolute()
Returns true if the path component (i.e. 
 | 
boolean | 
isAbsoluteAndSchemeAuthorityNull()
Returns true if the path component (i.e. 
 | 
boolean | 
isRoot()
Returns true if and only if this path represents the root of a file system. 
 | 
boolean | 
isUriPathAbsolute()
Returns true if the path component (i.e. 
 | 
static boolean | 
isWindowsAbsolutePath(String pathString,
                     boolean slashed)
Determine whether a given path string represents an absolute path on
 Windows. 
 | 
Path | 
makeQualified(FileSystem fs)
Deprecated. 
 
 | 
static Path | 
mergePaths(Path path1,
          Path path2)
Merge 2 paths such that the second path is appended relative to the first. 
 | 
Path | 
suffix(String suffix)
Adds a suffix to the final name in the path. 
 | 
String | 
toString()  | 
URI | 
toUri()
Convert this Path to a URI. 
 | 
void | 
validateObject()
Validate the contents of a deserialized Path, so as
 to defend against malicious object streams. 
 | 
public static final String SEPARATOR
public static final char SEPARATOR_CHAR
public static final String CUR_DIR
public static final boolean WINDOWS
public Path(String parent, String child)
parent - the parent pathchild - the child pathpublic Path(Path parent, String child)
parent - the parent pathchild - the child pathpublic Path(String parent, Path child)
parent - the parent pathchild - the child pathpublic Path(Path parent, Path child)
parent - the parent pathchild - the child pathpublic Path(String pathString) throws IllegalArgumentException
pathString - the path stringIllegalArgumentExceptionpublic Path(URI aUri)
aUri - the source URIpublic static Path getPathWithoutSchemeAndAuthority(Path path)
path - the source Pathpublic static Path mergePaths(Path path1, Path path2)
path1 - the first pathpath2 - the second path, to be appended relative to path1public static boolean isWindowsAbsolutePath(String pathString, boolean slashed)
pathString - the path string to evaluateslashed - true if the given path is prefixed with "/"public URI toUri()
public FileSystem getFileSystem(Configuration conf) throws IOException
conf - the configuration to use when resolving the FileSystemIOException - thrown if there's an issue resolving the
 FileSystempublic boolean isAbsoluteAndSchemeAuthorityNull()
public boolean isUriPathAbsolute()
public boolean isAbsolute()
isUriPathAbsolute().public boolean isRoot()
public String getName()
public Path getParent()
public Path suffix(String suffix)
suffix - the suffix to addpublic int compareTo(Path o)
compareTo in interface Comparable<Path>public int depth()
@Deprecated public Path makeQualified(FileSystem fs)
makeQualified(URI, Path)FileSystem's working
 directory.fs - the target FileSystempublic void validateObject()
                    throws InvalidObjectException
validateObject in interface ObjectInputValidationInvalidObjectException - if there's no URICopyright © 2023 Apache Software Foundation. All rights reserved.