views:

25

answers:

2

i have a java ee project which has a text file that uses a xml for loading data but i cannot address the test file xml which is behind the java test file. in the test file i use this statement:

InputStream inputFile = AddressTreeTest.class.getClassLoader().getResourceAsStream("test/testAdr.xml");

but when i run the file inputFile is null. what should I do?

+1  A: 

"when i run the file inputFile is null" - this suggests that the directory containing the /test folder is not in the CLASSPATH. If you put test/testAdr.xml in the CLASSPATH for your test case I believe your code will work as written.

duffymo
A: 

Try this (add "/")

InputStream inputFile = AddressTreeTest.class.getClassLoader().getResourceAsStream("/test/testAdr.xml");
ipingu