简体   繁体   English

如何在环境环境中将属性文件从jar加载到javascript代码

[英]How to load properties file from jar to javascript code in mirth environment

Hai I am trying to read properties file from jar to my javascript code in mirth environment . Hai我正在尝试在欢乐环境中将jar文件的属性文件读取到我的javascript代码中。 I wrote js code in transformer. 我在变压器中编写了js代码。

I kept jar file in lib folder. 我将jar文件保存在lib文件夹中。

It is showing exception like: 它显示如下异常:

The choice of Java method java.io.FileInputStream matching JavaScript argument types (null) is ambiguous; 匹配JavaScript参数类型(空)的Java方法java.io.FileInputStream的选择不明确; candidate methods are: 候选方法是:
FileInputStream(java.lang.String) FileInputStream(java.io.File) FileInputStream(java.lang.String)FileInputStream(java.io.File)
FileInputStream(java.io.FileDescriptor) (com.mirth.connect.server.MirthJavascriptTransformerException) FileInputStream(java.io.FileDescriptor)(com.mirth.connect.server.MirthJavascriptTransformerException)

Below is the code: 下面是代码:

importPackage(Packages.logproperties.*);
var prop=new Packages.java.util.Properties();
var fis=new     Packages.java.io.FileInputStream(Packages.java.lang.ClassLoader.getSystemResourceAsStream("Logs.properties"));
prop.load(fis);

Based on the error message is looks like you are calling FileInputStream with null . 根据错误消息,看起来您正在使用null调用FileInputStream

That means that Packages.java.lang.ClassLoader.getSystemResourceAsStream("Logs.properties") is returning null . 这意味着Packages.java.lang.ClassLoader.getSystemResourceAsStream("Logs.properties")返回null

Try using the absolute path to the file that you want to read, eg 尝试使用要读取的文件的绝对路径,例如

var fis=new Packages.java.io.FileInputStream("/full/path/to/Logs.properties");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM