Difference between File.renameTo and Files.move: which is faster?

Both File.renameTo and Files.move in Java can move the file. What is the difference between the two? And what has the best performance?

+8
java
source share
1 answer
 public boolean renameTo(File dest) 

Renames the file indicated by this abstract path.

Many aspects of the behavior of this method inherently depend on the platform : the renaming operation cannot move the file from one file system to another, and this may not work if the file with the destination abstract path already exists.

A source

But the move method can move or rename a file using a platform independent tool .

renameTo just returns a boolean type , but move returns the path to the target file

+7
source share

All Articles