String startPath = "";
String endPath = "";
File oldpaths = new File(startPath);
File newpaths = new File(endPath);
if (!newpaths.exists()) {
Files.copy(oldpaths.toPath(), newpaths.toPath());
System.out.println("文件移动成功!起始路径:" + startPath);
} else {
newpaths.delete();
Files.copy(oldpaths.toPath(), newpaths.toPath());
System.out.println("文件移动成功!起始路径:" + startPath);
}
Java将文件从一个文件夹移动到另一个文件夹(复制文件)
最新推荐文章于 2024-04-17 05:18:29 发布