企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 组件源码 ``` /** * <b>方法描述:</b> Base64解码 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2020-12-17 10:52:20 <br/> * * @param base64txt * 入参|base64编码内容|{@link java.lang.String} * @param outfile * 入参|保存到文件名,为空时解码到变量|{@link java.lang.String} * @param codeset * 入参|解码成字符串时的编码内容(GBK或UTF-8),输入空时将输出byte数组|{@link java.lang.String} * @param plaintxt * 出参|解码输出|{@link Object} * @return -1 异常<br/> * 1 成功<br/> */ @Component(label = "Base64解码", style = "判断型", type = "同步组件", comment = "如果解码输出到文件,返回文件名;否则直接将解码后内容输出。如果指定输出内容编码,输出字符串,否则输出byte数组", version = "1.0.0", deprecated = false, author = "admin", date = "2020-12-17 10:52:20") @InParams(param = {@Param(name = "base64txt", comment = "base64编码内容", type = java.lang.String.class), @Param(name = "outfile", comment = "保存到文件名,为空时解码到变量", type = java.lang.String.class), @Param(name = "codeset", comment = "解码成字符串时的编码内容(GBK或UTF-8),输入空时将输出byte数组", type = java.lang.String.class)}) @OutParams(param = {@Param(name = "plaintxt", comment = "解码输出", type = Object.class)}) @Returns(returns = {@Return(id = "-1", desp = "异常"), @Return(id = "1", desp = "成功")}) @Order(value = 2) public static ResultBase P_base64Dec(String base64txt, String outfile, String codeset) { String strErr = ""; try { if (outfile != null && outfile.trim().length() > 0) { byte[] buffer = new BASE64Decoder().decodeBuffer(base64txt); FileOutputStream out = new FileOutputStream(outfile); out.write(buffer); out.close(); return ResultBase.newSuccessResult(outfile); } else { byte[] buffer = new BASE64Decoder().decodeBuffer(base64txt); if (codeset != null && codeset.trim().length() > 1) { return ResultBase.newSuccessResult(new String(buffer, codeset)); } else { return ResultBase.newSuccessResult(buffer); } } } catch (Exception ex) { strErr = AppLog.errorMsg(ex); } return ResultBase.newExceptionResult("TPTC0003", "base64Dec-解码错误:" + strErr); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/c2/9a/c29a1ca5b17e6bcbbc195c494604aef7_1868x867.png) # 参数说明及示例 ## 入口参数 base64编码内容:经过 Base64 编码的数据,示例: `"YWJj"` 保存到文件名,为空时解码到变量:填写文件名,为空是解码到变量,示例: 解码成字符串时的编码内容(GBK或UTF-8),输入空时将输出byte数组:设置字符串的编码格式,为空时输出为字节数组,示例: `"utf-8"` ## 出口参数 解码输出:经过 Base64 解码,变成字符串或者文件,数组,示例: `__INNER__["result"]`