Groovy - 在tomcat服务器上找到csv文件并检索内容

时间:2016-10-28 05:10:04

标签: groovy soapui

我需要找到一种方法,使用groovy在tomcat服务器上查找文件。 该文件包含生成的唯一事务ID。下面的文件示例 date_time_transactionID_numbers.csv

所以从上面我知道transactionID,但是,该目录将包含超过100个csv文件。我如何找到实际文件?

def host = 'localhost'
def port = '8080'
def extractedValues = new      URL("http://${host}:${port}/share/test/working/test.csv").getText('UTF-8')
log.info extractedValues

1 个答案:

答案 0 :(得分:0)

如果您知道自己的交易ID号,就可以通过这样:

def host = 'localhost'
        def port = '8080'
        def transactionID_numbers = 100 //suppose you consider
        def date_time = "20_10_2016"    // suppose if your datetime variable like this
        def pathOfCsv = "${date_time}"+ "_" + "${transactionID_numbers}" + "." +"csv"


def extractedValues = new URL("http://${host}:${port}/share/test/working/${pathOfCsv}").getText('UTF-8')
log.info extractedValues
println "The file content is " + extractedValues

由于