Does Classloader loads normal files from dir in a JAR file
naresh pokuri
Greenhorn
Joined: Feb 13, 2010
Posts: 10
posted
0
what is the nature of Classloader, when a JAR file contains a dir named pref folder with .properties files and other xml files.
can we get reference to that files as stream by passing file names to ClassLoader.getReasourceAsStream() method.
Ireneusz Kordal
Ranch Hand
Joined: Jun 21, 2008
Posts: 423
posted
0
naresh pokuri wrote:what is the nature of Classloader, when a JAR file contains a dir named pref folder with .properties files and other xml files.
can we get reference to that files as stream by passing file names to ClassLoader.getReasourceAsStream() method.
Yes, we can.
You could pack to jar file whatever you want - images, properties, icons, text files, other jars, even database files.
If you want to retrieve resources from your application's jar file, try this example:
If you want to read file from other jar, try this:
naresh pokuri wrote:what is the nature of Classloader, when a JAR file contains a dir named pref folder with .properties files and other xml files.
can we get reference to that files as stream by passing file names to ClassLoader.getReasourceAsStream() method.
Just for future reference, it would have been quicker to just try it!