【问题标题】:Check file size in Groovy script在 Groovy 脚本中检查文件大小
【发布时间】:2019-02-26 13:37:50
【问题描述】:

我在SoapUI 中使用Groovy 脚本来列出给定目录中的所有文件。我使用此代码过滤空文件。

dir.eachFileRecurse (FileType.FILES) {
    if(file.length() > 0){file ->
        list << file
    }
}

我收到以下错误消息:

org.codehaus.groovy.control.MultipleCompilationErrorsException: 启动失败:Script8.groovy:16:期待'}',找到'->'@行 16,第 29 列。 if(file.length() > 0){file -> ^ org.codehaus.groovy.syntax.SyntaxException:期待'}',找到'->' @ 第 16 行,第 29 列。 org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:143) 在 org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:111) 在 org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:237) 在 org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:167) 在 org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931) 在 org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593) 在

【问题讨论】:

    标签: groovy soapui


    【解决方案1】:

    你不能在if操作中使用闭包

    应该有通常的块开始-结束:

    if(file.length() > 0){
        list << file
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-15
      • 1970-01-01
      • 1970-01-01
      • 2022-12-09
      • 1970-01-01
      相关资源
      最近更新 更多