> -----Original Message----- > From: Christopher Schultz [mailto:[EMAIL PROTECTED] > Sent: Saturday, April 14, 2007 2:51 PM > To: Tomcat Users List > Subject: Re: getResourceAsStream returning blank (NOT NULL) > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Tim, > > Tim Lucia wrote: > >> From: Johnny Kewl [mailto:[EMAIL PROTECTED] > >> InputStream in = > getClass().getResourceAsStream(sPackageNameWithSlashes); > >> > >> If the class name is com.myCo.data > >> > >> You put it in like this /com/myCo/data > >> > >> Also because this stuff looks for a class loader.... I dont think it > will > >> work in a STATIC class. > >> Use a normal class.... > > > > Static classes are loaded by a classloader. You can't say getClass(), > > however. Instead you would say MyClass.class.xxx()... > > Why not? The method isn't static, so there does exist a "this" on which > getClass() could be called.
If you have an instance, then of course you have a this and of course you can call getClass(). If you haven't got an instance, you can't call getClass(). I.e., public Foo { } Foo.getClass() -- illegal. Foo.class.getResourceAsStream() -- legal Presumably the poster above meant "singleton" (private default constructor) rather than Static, as classes aren't static. In this case, you cannot instantiate an instance and so you can't have a this pointer. Tim > > - -chris > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFGISKq9CaO5/Lv0PARAvYKAJ0a/qTw8T2s3wiLwGxhYkBDjiSPggCcDctP > H46j2Ec083778buiPzGNTg0= > =jJPi > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To start a new topic, e-mail: [EMAIL PROTECTED] > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To start a new topic, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]