ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 组件源码 ``` /** * @category 文件存在检查 * @param filepath * 入参|文件或目录|{@link java.lang.String} * @param isfile * 入参|true-文件检查,false-目录检查|boolean * @return 0 失败<br/> * 1 成功<br/> */ @InParams(param = { @Param(name = "filepath", comment = "文件或目录", type = java.lang.String.class), @Param(name = "isfile", comment = "true-文件检查,false-目录检查", type = boolean.class) }) @Returns(returns = { @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) @Component(label = "文件存在检查", style = "判断型", type = "同步组件", comment = "检查文件或目录是否存在", version = "1.0.0", deprecated = false, author = "test", date = "2018-01-23 09:44:39") public static ResultBase P_fileExist(String filepath, boolean isfile) { File file = new File(filepath); if (!file.exists()) { return ResultBase .newFailureResult("TPTF0025", "文件或目录不存在"); } if ((file.isDirectory() && isfile) || (file.isFile() && !isfile)) { return ResultBase .newFailureResult("TPTF0026",(file.isDirectory() ? "指定文件为目录" : "指定目录为文件")); } return ResultBase.newSuccessResult(); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/6a/8f/6a8f4ed594b677f0acd5ce14ca10ad44_1868x892.png) # 参数说明及示例 ## 入口参数 文件或目录:传入文件或者目录的绝对路径,示例: `"D:\\work\\CQYY\\workspace\\xxx.txt"` true-文件检查,false-目录检查:设置检查的是什么类型,示例: `true`