Path Interface Flashcards
Returns a path object representing the root of the given path, or null if the path does not have a root.
Path getRoot()
Returns the file name or directory name of the given path. Note that the file/directory name is the last element or name in the given path.
Path getFileName()
Returns the path object representing the parent of the given path, or null if no parent component exists for the path.
Path getParent()
Returns the number of file/directory names in the given path; returns 0 if the given path represents the root.
int getNameCount()
Returns the i^th file/directory name; the index 0 starts from the closest name to the root.
Path getName(int index)
Returns a path object that is part of this path object; the returned path object has a name that begins at beginIndex till the element at endIndex - 1. In other words, beginInedx is inclusive of the name in that index and exclusive of the name in endIndex. Throws IllegalArguementException if begin index is >= number of elements or endIndex number of elements.
Path subPath(int beginIndex, int endIndex)
Removes redundant elements in path such as . (dot symbol that indicates current directory) and ..(double dot symbol that indicates parent directory)
Path normalize()
Resolves a path against the given path.
Path resolve(Path or String other)
Returns true if the given path is an absolute path; false if not.
Boolean isAbsolute()
Returns true if this Path object starts with the given path, or false if not.
Path startsWith(String or Path path)
Returns the absolute path
Path toAbsolutePath()
Returns the URI from the path
URI toUri()
Returns an absolute path, but also normalizes it. Also resolves symbolic links. Unlike other methods, throws exception if target does not exist in filesystem.
toRealPath()
Checks equality of two path objects, returns true if equal, false if not.
equals()
Returns 0 if both paths are equal, a positive integer if this path is lexographically greater than the parameter path, and a negative integer if it is lexographically less.
compareTo()