ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 组件源码 ``` /** * <b>方法描述:</b> 文件拷贝 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-08 17:10:53 <br/> * * @param srcFile * 入参|原文件|{@link java.lang.String} * @param desFile * 入参|目标文件|{@link java.lang.String} * @return -1 异常<br/> * 0 失败<br/> * 1 成功<br/> */ @Component(label = "文件拷贝", style = "判断型", type = "同步组件", comment = "单个文件拷贝", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-08 05:10:53") @InParams(param = { @Param(name = "srcFile", comment = "原文件", type = java.lang.String.class), @Param(name = "desFile", comment = "目标文件", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase P_fileCopy(String srcFile, String desFile) { try { File s = new File(srcFile); if (!s.exists()) return ResultBase.newFailureResult("TPTF0002", "文件拷贝失败,源文件不存在,文件名:" + srcFile); String dstDir = new File(desFile).getParent(); if (!StringUtil.isEmpty(dstDir)) { new File(dstDir).mkdirs(); } FileInputStream in = new java.io.FileInputStream(srcFile); FileOutputStream out = new FileOutputStream(desFile); byte[] bt = new byte[1024]; int count; while ((count = in.read(bt)) > 0) { out.write(bt, 0, count); } in.close(); out.close(); return ResultBase.newSuccessResult(); } catch (IOException ex) { return ResultBase.newExceptionResult("TPTF0003", "文件拷贝失败,源文件:" + srcFile + ",目标文件:" + desFile + AppLog.errorMsg(ex)); } } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/8e/cd/8ecd3b8657e5a131670827d5d11258a1_1870x889.png) # 参数说明及示例 ## 入口参数 原文件:被拷贝的文件绝对路径,示例: `"D:\\work\\CQYY\\workspace\\xxx.txt"` 目标文件:拷贝到目标文件绝对路径,示例: `"D:\\work\\CQYY\\workspace\\yyy.txt"`