public static void consumeListFileExport(String sourceFilePath,
String destFilePath) throws IOException {
File src = new File(sourceFilePath);
if ((src.exists()) && (src.canRead())) {
File dest = new File(destFilePath);
try {
FileUtils.copyFile(src, dest);
} catch (IOException e) {
throw new IOException("文件拷贝异常: " + e);
}
} else {
throw new RuntimeException("源文件不存在或者不可读: " + sourceFilePath);
}
Common IO在项目中的应用
最新推荐文章于 2021-06-14 19:11:11 发布
本文介绍了一个简单的文件复制工具实现方法,该工具能够将指定路径的源文件复制到目标位置。如果源文件存在且可读,则使用Java的FileUtils进行复制操作;若源文件不存在或无法读取,则会抛出运行时异常。
383

被折叠的 条评论
为什么被折叠?



