The renameTo() method renames the file and returns true if the operation was successful. This method is heavily platform-dependent. It might not be able to move the file from one filesystem to another.
2. Method signature
- dest - the new abstract pathname for the named file
- true - if the renaming file succeeded; false otherwise
- SecurityException - when we do not have access to the file or directory
3.1. Snippet code that moves a file from path
In this article, we presented
renameTo() method available in the Java IO API that could be used to rename and also move a file to another directory.