How to read a file from within a the JAR. When both are present on the server
This is the sample code which we were using:
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(new FileInputStream("Data.xml"));
doc.getDocumentElement().normalize();
So when using the same code on local we can get the path using system.getProperties('user.dir')
.
Is there any way that we can get the path on JasperReports Server So that we can read the file. This particular code mentioned above is available in the JAR and xml is placed outside the JAR.
如果你知道你的文件在你的系统上,为什么你不使用绝对路径?
new FileInputStream("/path/on/my/system/Data.xml")
链接地址: http://www.djcxy.com/p/65806.html
上一篇: 如何实现不与if语句在烬手柄?