public interface Path extends Serializable
Path
represents a location in a
FileSystem
. Paths are normally
constructed via the methods available in Paths
.
Paths present a hierarchical structure for
locating resources, identifying a resource
based on a sequential traversal of elements,
typically starting from some root.
The methods of this interface deal only with
the structural aspects of paths, not with
the data which they identified.
To actually access the data represented by a path, use the
methods found in FileClient
.
Paths are identified using a URI-like syntax,
using a scheme prefix of file
scheme is
recognized, a scheme is not required;
path strings with no scheme are assumed to be
local files. Some examples of path strings are:
file:/home/myuser/myfile C:\temp\myfile ../siblingfile hdfs://namenode:9000/path/to/file
It is only necessary to implement a Path
if
writing a new file system scheme, in which case it
is necessary to also implement a FileSystemProvider
and FileSystem
as well.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
FileSystemProvider |
getFileSystemProvider()
Gets the file system provider for this path.
|
String |
getName()
Gets the last element of the path.
|
Path |
getParent()
Gets the path referring to the location containing
the path.
|
int |
hashCode() |
boolean |
isAbsolute()
Indicates whether the path is absolute
or relative.
|
Path |
resolve(String childPath)
Adds additional elements to the path.
|
Path |
toAbsolutePath()
Converts a relative path into an absolute
path.
|
File |
toFile()
Gets the local file corresponding to the path.
|
String |
toString()
Gets the string representation of the path.
|
String |
toURL()
Returns the URL string corresponding to this path.
|
FileSystemProvider getFileSystemProvider()
boolean isAbsolute()
For most file systems, all paths are absolute.
true
if the path starts
from the file system root, false
otherwise.Path toAbsolutePath()
Path getParent()
null
if this path is the root.String getName()
Path resolve(String childPath)
childPath
- theFile toFile()
null
.null
if it does not identify a
file on the local file system.String toURL()
null
if
this path cannot be mapped to a URL.String toString()
Paths.asPath(path.toString())
refers to the same location as path
.
However, it may not the case that
pathString.equals(Paths.asPath(pathString).toString())
.Copyright © 2020 Actian Corporation. All rights reserved.