Groovy - 从tomcat服务器读取文件 [英] Groovy - Reading files from tomcat server

查看:387
本文介绍了Groovy - 从tomcat服务器读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用Groovy检索文件内容。



以下是代码,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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆