Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #20085

Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream()

Newsgroups comp.lang.java.programmer
Date 2012-12-03 20:37 -0800
References <3c227741-7b7f-4cf8-b188-ce5268894031@googlegroups.com> <k9j0qj$ftg$1@dont-email.me> <890512f9-9df6-42dd-a151-993e09912ece@googlegroups.com> <k9jcdu$jdc$1@dont-email.me>
Message-ID <de4ec0f0-3168-40c1-b010-ab64f43e9f88@googlegroups.com> (permalink)
Subject Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream()
From Lew <lewbloch@gmail.com>

Show all headers | View raw


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

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() zyng <xsli2@yahoo.com> - 2012-12-03 11:29 -0800
  Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() markspace <-@.> - 2012-12-03 12:07 -0800
    Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() Lew <lewbloch@gmail.com> - 2012-12-03 14:04 -0800
      Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() markspace <-@.> - 2012-12-03 15:25 -0800
        Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() Lew <lewbloch@gmail.com> - 2012-12-03 20:37 -0800
  Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() zyng <xsli2@yahoo.com> - 2012-12-04 05:40 -0800
    Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() Lew <lewbloch@gmail.com> - 2012-12-04 12:57 -0800

csiph-web