Groovy - 从tomcat服务器读取文件 [英] Groovy - Reading files from tomcat server
问题描述
以下是代码,Soapui中的错误
portnumber =:8080
extractedValues = new File(// hostname+$ {portnumber}+/ share / test / working / test。 csv)。getText('UTF-8')
log.info(extractedValues)
Error:
java.io.FileNotFoundException:\\hostname:8080\share\test\working\test .csv(找不到网络路径)错误:54
我觉得问题在于端口号,因此为什么我将它传递给一个变量。
链接本身在登录服务器并从文件资源管理器尝试它时起作用。
看起来你正在读取一个托管在tomcat中的文件,即一个URL。 你会得到它的内容:
def host ='localhost'
def port ='8080'
def extractedValues = new URL(http:// $ {host}:$ {port} /share/test/working/test.csv).getText(' UTF-8')
log.info extractedValues
I'm not able to retrieve file contents using Groovy.
Below is the code, error in Soapui
portnumber = ":8080"
extractedValues = new File("//hostname"+"${portnumber}"+"/share/test/working/test.csv").getText('UTF-8')
log.info(extractedValues)
Error:
java.io.FileNotFoundException: \\hostname:8080\share\test\working\test.csv (The network path was not found) error at line: 54
I feel like the issue is with the port number, thus why I'm passing it in a variable.
The link itself works when logged on the server and trying it from file explorer.
Looks like you are reading a file hosted in a tomcat i.e., an URL.
Here is how you would get the contents of it:
def host = 'localhost'
def port = '8080'
def extractedValues = new URL("http://${host}:${port}/share/test/working/test.csv").getText('UTF-8')
log.info extractedValues
这篇关于Groovy - 从tomcat服务器读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!