XML 转换导致 FileNotFoundException [英] XML Transform results in FileNotFoundException
问题描述
由于缺乏信息,我之前发布的问题已关闭.
如果我在这里遗漏了什么,请告诉我.转换器似乎将 file:/添加到我的文件路径的开头.
我在 Solaris 环境中工作,以下是应用转换时发生的情况:
DOMSource sourcexml = new DOMSource(doc);StreamResult resultxml = new StreamResult(new File("file.xml"));转换器.transform(sourcexml, resultxml);
我得到的例外是:
javax.xml.transform.TransformerException: java.io.FileNotFoundException: file:/opt/origenate/or_dev87/apps/documentarchive/file.xml(没有这样的文件或目录)
请注意,该文件存在于/opt/origenate/or_dev87/apps/documentarchive/file.xml 中,但转换器对象正在寻找文件:/opt/origenate/or_dev87/apps/documentarchive/file.xml.>
为什么要附加文件:/?无论如何我可以删除它吗?
尝试执行以下代码:
DOMSource sourcexml = new DOMSource(doc);StreamResult resultxml = new StreamResult(new File("file.xml").getAbsolutePath());转换器.transform(sourcexml, resultxml);
The earlier question I posted is closed because of lack of information.
Please let me know if I am missing something here. The transformer seems to be adding file:/ to the beginning of my file path.
I am working in a Solaris environment, and here is what happens when the transform gets applied:
DOMSource sourcexml = new DOMSource(doc);
StreamResult resultxml = new StreamResult(new File("file.xml"));
transformer.transform(sourcexml, resultxml);
The exception I get is:
javax.xml.transform.TransformerException: java.io.FileNotFoundException: file:/opt/origenate/or_dev87/apps/documentarchive/file.xml (No such file or directory)
Note, the file exists in /opt/origenate/or_dev87/apps/documentarchive/file.xml, but the transformer object is looking for file:/opt/origenate/or_dev87/apps/documentarchive/file.xml.
Why does it append the file:/? Is there anyway I can remove it?
Try to execute below code:
DOMSource sourcexml = new DOMSource(doc);
StreamResult resultxml = new StreamResult(new File("file.xml").getAbsolutePath());
transformer.transform(sourcexml, resultxml);
这篇关于XML 转换导致 FileNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!