Java: How to Read a Resource Inside a Jar
I was packaging my web service API as a Jar file. The API has to access a WSDL xml file.
The file structure of the Jar looks like this:
If the class is also in the same jar file, you can simply read the file like this:
(in URL format)
final URL url = this.getClass().getResource(”/webservice.asmx.xml”);(in InputStream format)
final InputStream is = this.getClass().getResourceAsStream(”/webservice.asmx.xml”);

February 24th, 2009 at 6:39 am
Thank you!