Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream()
zyng wrote:
I have gone through the ClassLoader API doc
(http://docs.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#getSystemResource(java.lang.String))
several times and still don't get a clue about it.
Gee, less than five minutes' online search turned up this link:
http://littletutorials.com/2008/03/26/locating-resources-in-java/
Did that article's assertions check out for you?
This post cited ClassLoader API(http://www.xyzws.com/Servletfaq/what-is-different-between-classloadergetresourceasstream-and-classgetresourceasstream/21).
However, in the API doc, I cannot find any information about leading slash. I guess Sun(or Oracle) has modified the API for new version.
You guess based on what? There has to be *evidence* of such a change to make such a claim.
Anyway, I cannot get the answer from ClassLoader API.
That does seem to be a hole in the API docs, but surely you have your answer by now.
I found this post which has answered me most part:
http://www.dtumanov.com/post/3355401249/java-resource-loading
In the end, a quick-and-dirty code example will answer your questions for you.
--
Lew