/** * 文件拷贝 * @param srcFile * @param destFile */ public static void zeroCopyFile(File srcFile,File destFile){ if (srcFile == null || destFile == null) { return; } try { FileChannel source = new FileInputStream(srcFile).getChannel(); FileChannel destination = new FileOutputStream(destFile).getChannel(); source.transferTo(0, source.size(), destination); } catch (IOException e) { log.error("copy error: {}", e); } } /** * 文件流拷贝 * @param srcFile * @param destFile */ public static void zeroCopyFileStream(FileInputStream srcFile,FileOutputStream destFile){ if (srcFile == null || destFile == null) { return; } try { FileChannel source = srcFile.getChannel(); FileChannel destination = destFile.getChannel(); source.transferTo(0, source.size(), destination); } catch (IOException e) { log.error("copy error: {}", e); } }
zeroCopy_零拷贝_java
最新推荐文章于 2024-06-07 16:43:58 发布