什么是非Windows系统中绝对路径的URL等价物?

Sud*_*hir 1 java xml url birt

我从Linux操作系统运行BIRT时遇到异常.

引起:org.eclipse.datatools.connectivity.oda.OdaException:无协议:/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());
}
Run Code Online (Sandbox Code Playgroud)

这意味着代码正在尝试将上面指定的文件路径转换为URL并且失败.

所以我的问题是如何将非Windows路径转换为URL?它应该以file:///作为前缀吗?

Kon*_*rus 5

Windows与否,本地文件的所有URL都以file://.这是协议前缀.

所以你的文件将是:

file://+ /home/lsingh/reporting/tmp/execution1279514184559/TDReport.xml=file:///home/lsingh/reporting/tmp/execution1279514184559/TDReport.xml