Files Class
Package: java.nio.file
The Files
class consists entirely of static methods that can perform operations on files, which are represented by Path
objects. For example, to delete a file, you first get a Path
object that points to the file. Then, you pass the Path
object to the delete method of the Files
class to delete the file.
Methods
Method |
Description |
|
Copies the source file to the target file. |
|
Moves or renames the source file to the target path and deletes the original file. |
|
Creates a directory. All directories in the path up to the directory that the new directory is to be created within must already exist. |
|
Creates a new directory, including any intermediate directories in the path. |
|
Creates a file. |
|
Deletes the file or directory. The method throws an exception if the file or directory doesn’t exist or couldn’t be deleted. |
|
Deletes the file or directory if it exists. The method doesn’t throw an exception if the file or directory doesn’t exist. |
|
Returns |
Get Java For Dummies Quick Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.