1、FileUtils.copyFile方法
copyFile方法有多种重载形式,下面截图只是其中比较简单的一种,详细见官方文档
2、业务代码:
private File copyFile(Long baseTime, int orgId, int typeId, String sourcePath, String fileName) throws IOException {String time = DateUtils.convertDateToString(DateUtils.timestampToDate(baseTime), "yyyyMMdd");sourcePath = String.format("D:/%s/%s", sourcePath, fileName);String targetPath = String.format("D:/fusion12h_parse/%s/%s/%s/%s", time, orgId, typeId, fileName);File sourceFile = new File(sourcePath);File targetFile = new File(targetPath);FileUtils.copyFile(sourceFile, targetFile);return targetFile;
}