需要先添加maven依赖
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
然后调用
FileUtils.copyFile(new File("旧文件路径"), new File("新文件路径"));