Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream()
markspace wrote:
Lew wrote:
The names of the respective methods in this case are *not* named the
same!
Huh, I totally misread that somehow. I guess I need to pay closer
attention.
Well, the two classes do, in fact, sport a method of the same name, 'getResourceAsStream()'.
Your reply applies to those methods.
But the basis of the question is flawed - why should the same-named method in a different type
behave the same? Examples abound where they don't. Heck, two different 'Runnable' types don't
even do the same things in their 'run()' methods! And that's in the same type!
(To those who don't know me, the exclamation points are hints that I'm up to some
rhetorical mischief.)
The fact that the original question didn't even match up same-named methods when there were
such, and ones that do nearly the same thing at that, is bit interesting but doesn't materially
alter the situation. Method names are not determinant of behavior in and of themselves, although
in the case of interfaces like 'Runnable' they are indicative of a formal contract.
One really needs to turn to the API docs to resolve the original question. To make matters worse,
there's another 'getResourceAsStream()' in the Java EE API
<http://docs.oracle.com/javaee/6/api/javax/servlet/ServletContext.html#getResourceAsStream(java.lang.String)>
and it doesn't use 'ClassLoader' at all!
What's to explain, OP? The Javadocs tell all you need to know.
--
Lew