If it is already in the classpath and in the same package, use
URL url = getClass().getResource("b.xml"); File file = new File(url.getPath());
OR, read it as an InputStream :
InputStream input = getClass().getResourceAsStream("b.xml");
Inside the static method, you can use
InputStream in = YourClass.class.getResourceAsStream("b.xml");
If your file is not in the same package as the class with which you are trying to access the file, then you must specify its relative path, starting with '/' .
ex : InputStream input = getClass().getResourceAsStream ("/resources/somex.cfg.xml");which is in another jar resource folder
NINCOMPOOP
source share