public abstract class AbstractPath extends Object implements Path
Path
interface to minimize the effort required to implement this interface.Modifier | Constructor and Description |
---|---|
protected |
AbstractPath()
Creates a new path.
|
Modifier and Type | Method and Description |
---|---|
boolean |
endsWith(String other)
Tests if this path ends with a
Path , constructed by converting the given path string. |
Path |
getFileName()
Returns the name of the file or directory denoted by this path as a
Path object. |
Path |
getName(int index)
Returns a name element of this path as a
Path object. |
Iterator<Path> |
iterator()
Returns an iterator over the name elements of this path.
|
WatchKey |
register(WatchService watcher,
WatchEvent.Kind<?>... events)
Registers the file located by this path with a watch service.
|
Path |
resolve(String other)
Converts a given path string to a
Path and resolves it against this Path . |
Path |
resolveSibling(Path other)
Resolves the given path against this path's
parent path. |
Path |
resolveSibling(String other)
Converts a given path string to a
Path and resolves it against this path's parent path. |
boolean |
startsWith(String other)
Tests if this path starts with a
Path , constructed by converting the given path string. |
File |
toFile()
Returns a
File object representing this path. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compareTo, endsWith, equals, getFileSystem, getNameCount, getParent, getRoot, hashCode, isAbsolute, normalize, register, relativize, resolve, startsWith, subpath, toAbsolutePath, toRealPath, toString, toUri
forEach, spliterator
public Path getFileName()
Path
object.
This implementation returns getName(i)
, where i
is equal to Path.getNameCount()
- 1
.
If getNameCount()
returns 0
this method returns null
.
getFileName
in interface Path
public Path getName(int index)
Path
object.
This implementation calls subpath(index, index + 1)
.
public boolean startsWith(String other)
Path
, constructed by converting the given path string.
This implementation uses this path's FileSystem
to convert
the given
string into a Path
, then calls Path.startsWith(Path)
.
startsWith
in interface Path
public boolean endsWith(String other)
Path
, constructed by converting the given path string.
This implementation uses this path's FileSystem
to convert
the given
string into a Path
, then calls Path.endsWith(Path)
.
public Path resolve(String other)
Path
and resolves it against this Path
.
This implementation uses this path's FileSystem
to convert
the given
string into a Path
, then calls Path.resolve(Path)
.
public Path resolveSibling(String other)
Path
and resolves it against this path's parent
path.
This implementation uses this path's FileSystem
to convert
the given
string into a Path
, then calls resolveSibling(Path)
.
resolveSibling
in interface Path
public Path resolveSibling(Path other)
parent
path.
This implementation returns getParent().
resolve(other)
, or other
if this path has no parent.
resolveSibling
in interface Path
public File toFile()
File
object representing this path.
This implementation will always throw an UnsupportedOperationException
as per the contract of Path.toFile()
.
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) throws IOException
This implementation will call Path.register(WatchService, WatchEvent.Kind[], WatchEvent.Modifier...)
with an empty array of modifiers.
register
in interface Path
register
in interface Watchable
IOException
public Iterator<Path> iterator()
This implementation returns an iterator that uses Path.getNameCount()
to determine whether or not there are more elements,
and getName(int)
to return the elements.
Copyright © 2016–2023. All rights reserved.