企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 组件源码 ``` /** * <b>方法描述:</b> 文件合并 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-08 17:22:21 <br/> * * @param fileList * 入参|待合并的文件名| * {@link com.ylink.ide.trade.runtime.context.JavaList} * @param outFile * 入参|合并输出的文件名|{@link java.lang.String} * @return -1 异常<br/> * 1 成功<br/> */ @Component(label = "文件合并", style = "判断型", type = "同步组件", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-08 05:22:21") @InParams(param = { @Param(name = "fileList", comment = "待合并的文件名", type = com.ylink.ide.trade.runtime.context.JavaList.class), @Param(name = "outFile", comment = "合并输出的文件名", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "1", desp = "成功") }) public static ResultBase P_mergeFiles(JavaList fileList, String outFile) { FileChannel outChannel = null; if(StringUtil.isBlank(outFile)) return ResultBase.newFailureResult("TPTF0050", "输出文件名不能为空"); if(fileList==null||fileList.isEmpty()) return ResultBase.newFailureResult("TPTF0050", "待合并文件列表能为空"); try { outChannel = (new FileOutputStream(outFile)).getChannel(); for (Object iterm : fileList) { String f = (String) iterm; FileChannel fc = (new FileInputStream(f)).getChannel(); ByteBuffer bb = ByteBuffer.allocate(8192); while (fc.read(bb) != -1) { bb.flip(); outChannel.write(bb); bb.clear(); } fc.close(); } return ResultBase.newSuccessResult(); } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTF0035", "合并文件失败," + AppLog.errorMsg(e)); } finally { try { if (outChannel != null) { outChannel.close(); } } catch (IOException arg10) { AppLog.error(arg10); } } } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/c4/08/c4083e2223e840133b44ac7f8e4d9bcc_1868x893.png) # 参数说明及示例 ## 入口参数 待合并的文件名:需要合并的文件绝对路径,示例: `["D:\\work\\CQYY\\workspace\\abc.txt", "D:\\work\\CQYY\\workspace\\123.txt"]` 合并输出的文件名:合并后的文件绝对路径,示例: `"D:\\work\\CQYY\\workspace\\xxx.txt"`