ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 组件源码 ``` /** * <b>方法描述:</b> ZIP文件解压缩 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-08 17:20:05 <br/> * * @param zipFile * 入参|ZIP文件名|{@link java.lang.String} * @param destPath * 入参|解压目录|{@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:05") @InParams(param = { @Param(name = "zipFile", comment = "ZIP文件名", type = java.lang.String.class), @Param(name = "destPath", comment = "解压目录", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase P_unzipFile(String zipFile, String destPath) { File file = new File(zipFile); if (!file.exists()) { return ResultBase.newFailureResult("TPTF0031", "文件名称:" + zipFile + "不存在"); } try { ZipFile zf = new ZipFile(file); Enumeration<? extends ZipEntry> entries = zf.entries(); ZipEntry entry = null; while (entries.hasMoreElements()) { entry = entries.nextElement(); if (entry.isDirectory()) { String dirPath = destPath + File.separator + entry.getName(); File dir = new File(dirPath); dir.mkdirs(); } else { File f = new File(destPath + File.separator + entry.getName()); if (!f.exists()) { String dirs = f.getParent(); File parentDir = new File(dirs); parentDir.mkdirs(); } f.createNewFile(); InputStream is = zf.getInputStream(entry); FileOutputStream fos = new FileOutputStream(f); int count; byte[] buf = new byte[8192]; while ((count = is.read(buf)) != -1) { fos.write(buf, 0, count); } is.close(); fos.close(); } } zf.close(); return ResultBase.newSuccessResult(); } catch (Exception ex) { AppLog.error(ex); return ResultBase.newExceptionResult("TPTF0032", "压缩文件" + zipFile + "解压失败," +AppLog.errorMsg(ex)); } } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/86/8a/868ae2fd9da0438904db395ce8d37d28_1870x890.png) # 参数说明及示例 ## 入口参数 ZIP文件名:ZIP 文件所在的绝对路径,示例: `"D:\\work\\CQYY\\workspace\\abc.zip"` 解压目录:ZIP 文件解压后的目录,示例: `"D:\\work\\CQYY\\workspace\\"`