从 Linux 操作系统运行 BIRT 时出现以下异常。
引起:org.eclipse.datatools.connectivity.oda.OdaException:无协议(protocol):/home/lsingh/reporting/tmp/execution1279514184559/TDReport.xml
其中“/home/lsingh/reporting/tmp/execution1279514184559/TDReport.xml”是我的 XML 数据文件。
当我查看 BIRT 中“org.eclipse.birt.report.data.oda.xml.util.XMLDataInputStreamCreator”类的代码时,我发现异常来自以下代码段。
catch (MalformedURLException e)
{
throw new OdaException(e.getLocalizedMessage());
}
这意味着代码试图将上面指定的文件路径转换为 URL,但失败了。
所以我的问题是如何将非 Windows 路径转换为 URL? 它应该以 file:///为前缀吗?
最佳答案
无论是否是 Windows,本地文件的所有 URL 都以 file://
开头。那是协议(protocol)前缀。
所以你的文件将是:
file://
+ /home/lsingh/reporting/tmp/execution1279514184559/TDReport.xml
= file:///home/lsingh/reporting/tmp/execution1279514184559/TDReport.xml
关于java - 非windows系统中绝对路径的URL等价物是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3279045/