| Method |
Description |
| Path getFileName() |
Returns the name of the file or directory denoted by this path as a Path object |
| FileSystem getFileSystem() |
Returns the file system that created this object |
| Path getName(int index) |
Returns a name element of this path as a Path object |
| int getNameCount() |
Returns the number of name elements in the path |
| Path getParent() |
Returns the parent path, or null if this path does not have a parent |
| 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 toAbsolutePath() |
Returns a Path object representing the absolute path of this path |
| File toFile() |
Returns a File object representing this path |
| URI toUri() |
Returns a URI to represent this path |
| Method |
Description |
| static Path copy(Path source, Path target, CopyOption... options) |
Copies a file to a target file |
| static void delete(Path path) |
Deletes a file. |
| static boolean deleteIfExists(Path path) |
Deletes a file if it exists. |
| static boolean isDirectory(Path path, LinkOption... options) |
Tests whether a file is a directory |
| static Path move(Path source, Path target, CopyOption... options) |
Moves or renames a file to a target file |
| static DirectoryStream<Path> newDirectoryStream(Path dir) |
Opens a directory, returning a DirectoryStream to iterate over all entries in the directory |
| static String probeContentType(Path path) |
Probes the content type of a file |
| static List<String> readAllLines(Path path, Charset cs) |
Reads all lines from a file |
| static long size(Path path) |
Returns the size of a file (in bytes) |
| static Path walkFileTree(Path start, FileVisitor<? super Path> visitor) |
Walks a file tree |