tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Polliard <tho...@polliard.com>
Subject Re: getResourceAsStream returning blank (NOT NULL)
Date Mon, 16 Apr 2007 16:21:30 GMT
Tim Lucia wrote:
>
>> -----Original Message-----
>> From: Christopher Schultz [mailto:chris@christopherschultz.net]
>> Sent: Saturday, April 14, 2007 2:51 PM
>> To: Tomcat Users List
>> Subject: Re: getResourceAsStream returning blank (NOT NULL)
>>
> Tim,
>
> Tim Lucia wrote:
> >>>> From: Johnny Kewl [mailto:john@kewlstuff.co.za]
> >>>> 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
That is correct, Singleton
>>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message