企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 组件源码 /** * <b>方法描述:</b> 截取文件路径 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2019-06-21 15:58:09 <br/> * * @param path * 入参|全路径|{@link java.lang.String} * @param prex * 入参|前缀|{@link java.lang.String} * @param nf * 出参|路径|{@link java.lang.String} * @return 0 失败<br/> * 1 成功<br/> */ @Component(label = "截取文件路径", style = "判断型", type = "同步组件", version = "1.0.0", deprecated = false, author = "admin", date = "2019-06-21 03:58:09") @InParams(param = { @Param(name = "path", comment = "全路径", type = java.lang.String.class), @Param(name = "prex", comment = "前缀", type = java.lang.String.class) }) @OutParams(param = { @Param(name = "nf", comment = "路径", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase A_splitPath(String path, String prex) { if (path.endsWith(".xls")) { path += "x"; } File file = new File(path); String rf = ""; if (file.exists()) { rf = path.replace(prex, ""); } return ResultBase.newSuccessResult(rf); } 交易中组件使用方式: ![](https://img.kancloud.cn/1b/01/1b017a1d0a39c485fd8f9c31a3a6e4f0_950x750.jpg) ## 参数说明及示例 全路径:文件绝对路径,示例: `"/home/usr/local/test.xls"` 前缀:不需要截取的路径,示例: `"/home/usr/"` 路径:输出截取后的文件路径,示例: `__INNER__["filepath"]` > 根据输入的文件全路径以及前缀,截取文件路径,如示例中最终输出的路径为`local/test.xlsx`