Re: How to load properties as resources?
- From: Roedy Green <my_email_is_posted_on_my_website@xxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 00:27:08 GMT
On 30 Jan 2006 16:16:33 -0800, "Mr. Land" <graftonfot@xxxxxxxxx>
wrote, quoted or indirectly quoted someone who said :
>ClassLoader cl = SystemProperties.class.getClassLoader();
>if (null != cl)
>{
> InputStream is = cl.getResourceAsStream("Common.properties");
> ...more code to load properties from the stream
>}
I'd do it more directly with:
InputStream fis = MyApp.class.getResourceAsStream( "Common.properties"
);
Your way is going to get into trouble on two counts:
1. unsigned Applets are not permitted to tinker with Classloaders
2. the classloader for java.lang.SystemProperties is not necessarily
the same one used for finding your App and its resources.
see http://mindprod.com/jgloss/resource.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
.
- Follow-Ups:
- Re: How to load properties as resources?
- From: Mr. Land
- Re: How to load properties as resources?
- References:
- How to load properties as resources?
- From: Mr. Land
- How to load properties as resources?
- Prev by Date: How to load properties as resources?
- Next by Date: Encryption/Decryption Streams Cause UTFDataFormatException
- Previous by thread: How to load properties as resources?
- Next by thread: Re: How to load properties as resources?
- Index(es):
Relevant Pages
|