Forum Stats

  • 3,827,153 Users
  • 2,260,746 Discussions


File.renameTo acting slower

Alejandro Tovar Lanz
Alejandro Tovar Lanz Member Posts: 1,631 Bronze Trophy
edited Feb 17, 2017 11:42AM in Java Programming


We are using this method as part of automation process. After a lot of debugging we hit the head of the nail by isolating the call file file.renameTo(destFile);

Version 1.6

This is a PROD environment and it takes around 3 seconds to the the copy. In QA the same method goes through immediately. According to the documentation:

Many aspects of the behavior of this method are inherently

     * platform-dependent: The rename operation might not be able to move a

     * file from one filesystem to another, it might not be atomic, and it

     * might not succeed if a file with the destination abstract pathname

     * already exists.  The return value should always be checked to make sure

     * that the rename operation was successful.

So this may be an issue of the OS rather than the java class.

Any idea how to go about this?




This discussion has been closed.