jcldjgbfilj
New Member
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\[code\]DocumentBuilder.parse(InputStream)\[/code\]The problem is when I try to get the InputStream using \[code\]getResourceAsStream("res/xml/items.xml")\[/code\]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:\[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();}\[/code\]This still gives me null.