企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 组件源码 ``` /** * <b>方法描述:</b> ZIP文件压缩 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-08 17:20:43 <br/> * * @param srcFile * 入参|待压缩文件或目录 |{@link java.lang.String} * @param zipFile * 入参|解压输出文件|{@link java.lang.String} * @return -1 异常<br/> * 0 失败<br/> * 1 成功<br/> */ @Component(label = "ZIP文件压缩", style = "判断型", type = "同步组件", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-08 05:20:43") @InParams(param = { @Param(name = "srcFile", comment = "待压缩文件或目录 ", type = java.lang.String.class), @Param(name = "zipFile", comment = "解压输出文件", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase P_zipFile(String srcFile, String zipFile) { File file = new File(srcFile); if (!file.exists()) { return ResultBase.newFailureResult("TPTF0033", "压缩原文件或目录" + srcFile + "不存在"); } ZipOutputStream zos = null; try { FileOutputStream fos = new FileOutputStream(new File(zipFile)); zos = new ZipOutputStream(fos); compress(file, zos, file.getName(), true); return ResultBase.newSuccessResult(); } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTF0034", "zipFile-压缩文件或目录" + srcFile + "失败," + AppLog.errorMsg(e)); } finally { if (zos != null) { try { zos.close(); } catch (IOException e) { AppLog.error(e); } } } } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/d7/6b/d76be4a9a29553626766c440f7269d1d_1870x889.png) # 参数说明及示例 ## 入口参数 待压缩文件或目录:待压缩文件或目录的结对路径,示例: `"D:\\work\\CQYY\\workspace\\abc.txt"` 解压输出文件:输入的绝对路径,示例: `"D:\\work\\CQYY\\workspace\\abc.zip"`