You can look at commons-io FileUtils.moveFile . This method tries File.renameTo , and if that fails, it tries to copy and delete the file (for example, when moving from one drive to another).
If you use File.renameTo directly (which should be enough if you only want to rename the file in the same directory), make sure you evaluate the return boolean!
source share