public static void replaceFile(File newFile, File oldFile) throws IOException {
    if (!newFile.renameTo(oldFile)) {
      // some OSs need to delete the old file before renaming to it
      if (!oldFile.delete()) {
        throw new IOException(String.format("Cannot delete old user file : %s", oldFile.getPath()));
      }
      if (!newFile.renameTo(oldFile)) {
        throw new IOException(
            String.format("Cannot replace old user file with new one : %s", newFile.getPath()));
      }
    }
  }
Replace newFile with oldFile. If the file system does not support atomic file replacement then
delete the old file first.

@param newFile the new file.
@param oldFile the file to be replaced.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/IOUtils.java