I am having troubles loading an XML file within my java game. Here is where the file is located, (from Eclipse):
I have been doing research, and apparently to use the xml file in a JAR file, I need to call
DocumentBuilder.parse(InputStream)
The problem is when I try to get the InputStream using getResourceAsStream("res/xml/items.xml")
it always returns null.
How could I make it not return null? I don't want to put my res folder inside of my "src" folder, but is there some setting in Eclipse that I need to set? What would the correct String of the path be? Thanks!
Edit:
My code:
try {
DocumentBuilder db = dbf.newDocumentBuilder();
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("res/xml/items.xml");
dom = db.parse(is);
} catch(Exception e) {
e.printStackTrace();
}
This still gives me null.