- All Implemented Interfaces:
Comparable<Path>
- Direct Known Subclasses:
FileSystemWrapper.PathWrapper
As there is no concept of "working directory" in this API, the path is always absolute. However, the path may be interpreted from a different effective root by a file system.
Each file system may limit the length of path names or total paths, but
there is no limit imposed within Path
itself.
The path separator is always "/", even on platforms that do otherwise.
The root path is an empty string (and the only path name that may be an empty string). In string form, the root path by itself is represented as "/".
Paths are case-sensitive, even on platforms that do otherwise.
- Author:
- AO Industries, Inc.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPath
(FileSystem fileSystem) Constructs the root path for the given file system.Constructs a child path of the given parent. -
Method Summary
Modifier and TypeMethodDescriptionint
Compares two paths in lexical order.boolean
Two paths are equal if they are of the same depth and have equal names.boolean
String[]
explode()
Explodes this path into a set of names, not including the empty root name itself.String[]
Explodes this path to the given array.int
getDepth()
Gets the depth of this path.Gets the file system this path belongs to and is valid for.getName()
Gets the name of this part of the path.Gets the parent of this path.int
hashCode()
toString()
Gets a string representation of the path.void
toString
(Appendable out) Gets a string representation of the path.
-
Field Details
-
SEPARATOR
public static final char SEPARATOR- See Also:
-
SEPARATOR_STRING
-
-
Constructor Details
-
Path
Constructs the root path for the given file system. This will always be the empty path (""). -
Path
Constructs a child path of the given parent.- Parameters:
parent
- Must not benull
.name
- Must not be""
. Must not contain theSEPARATOR
character.- Throws:
InvalidPathException
- See Also:
-
-
Method Details
-
equals
-
equals
Two paths are equal if they are of the same depth and have equal names. Two paths on different file systems can be equal. -
hashCode
public int hashCode() -
compareTo
Compares two paths in lexical order.- Specified by:
compareTo
in interfaceComparable<Path>
-
toString
Gets a string representation of the path. The root is the separator by itself ("/"). -
toString
Gets a string representation of the path. The root is the separator by itself ("/").- Throws:
IOException
- See Also:
-
getFileSystem
Gets the file system this path belongs to and is valid for. -
getParent
Gets the parent of this path. Only the root will have a null parent. -
getName
Gets the name of this part of the path. -
getDepth
public int getDepth()Gets the depth of this path. The root has a zero depth. This is also the number of non-root names in this path, such as the number of elements that will be returned fromexplode()
.- See Also:
-
explode
Explodes this path into a set of names, not including the empty root name itself. The root path is represented by an empty array.- See Also:
-
explode
Explodes this path to the given array. If the array is not filled, the element one past the last name will be set to null.- Returns:
- the array parameter
- Throws:
ArrayIndexOutOfBoundsException
- if the provided array is of insufficient length- See Also:
-