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 |
Comments
|
Posted By Naidu On 13-Jul-11 08:10:03 PM
good article sir
|
|
Posted By Manogna On 13-Jul-11 08:39:08 PM
Good one, sir. I really don't understand how most of these basic features were not there till now. Perfect programmatic explanation(as always). Thank you, Sir.
|
|
Posted By Sayan On 13-Oct-12 01:50:12 AM
Any ideas how these features are compatible with Java 6? Is there a workaround if you want to use these features with Java 6 code and avoid a Java 7 upgrade. Understand there are lot of cool features in Java 7 and I'd like to use some of them like the ones mentioned above.
|