Search code examples
javaxmlfilepathrelative-path

XML File Extraction - relative path doesn't work


Really tired to search, it's just flooded with these kind of problems. I am trying to:

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

properties.loadFromXML(inputStream);

Throws me null pointer exception

File located under com\xxx\xxxxx\internal\props.xml I've tried with dots, slashes, I did search, I tried to understand - http://www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html?page=2 , got completely confused.


Solution

  • Why don't you try with "/com/xxx/xxxxx/internal/props.xml" instead. Or just "props.xml" if DBConnection resides in the same package as th xml file.