【问题标题】:XML File Extraction - relative path doesn't workXML 文件提取 - 相对路径不起作用
【发布时间】:2011-12-09 19:31:51
【问题描述】:

搜索真的很累,只是充斥着这些问题。我正在尝试:

InputStream inputStream =  DBconnection.class.getResourceAsStream("com.xxx.xxxxx.internal.props.xml");      
Properties properties = new Properties();

properties.loadFromXML(inputStream);

抛出空指针异常

位于 com\xxx\xxxxx\internal\props.xml 下的文件 我试过点,斜线,我搜索过,我试着理解 - http://www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html?page=2 ,完全糊涂了。

【问题讨论】:

    标签: java xml file path relative-path


    【解决方案1】:

    您为什么不尝试使用“/com/xxx/xxxxx/internal/props.xml”来代替。或者如果 DBConnection 与 xml 文件位于同一个包中,则只是“props.xml”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-15
      • 2014-07-11
      • 1970-01-01
      • 2017-07-12
      • 2013-02-19
      • 2015-08-30
      • 2011-03-17
      相关资源
      最近更新 更多