2013-03-15 68 views
2

我發佈的前面的問題由於缺乏信息而關閉。
請讓我知道,如果我在這裏失去了一些東西。變壓器似乎正在將文件:/添加到我的文件路徑的開頭。XML轉換結果FileNotFoundException

我在Solaris環境中工作,而這裏是當變換得到應用會發生什麼:

DOMSource sourcexml = new DOMSource(doc); 
StreamResult resultxml = new StreamResult(new File("file.xml")); 
transformer.transform(sourcexml, resultxml); 

我得到的例外是:

javax.xml.transform.TransformerException: java.io.FileNotFoundException: file:/opt/origenate/or_dev87/apps/documentarchive/file.xml (No such file or directory) 

注意,該文件存在於/ opt/origenate/or_dev87/apps/documentarchive/file.xml,但變換器對象正在查找文件:/opt/origenate/or_dev87/apps/documentarchive/file.xml。

它爲什麼附加文件:/?無論如何,我可以刪除它嗎?

回答

5

嘗試執行下面的代碼:

DOMSource sourcexml = new DOMSource(doc); 
StreamResult resultxml = new StreamResult(new File("file.xml").getAbsolutePath()); 
transformer.transform(sourcexml, resultxml);