Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 3 of 3
loadProperties() convenience method decides which classloader to use for loading the resource. The solution shown is reasonable but not perfect;
you might consider using techniques described in "Find a Way Out of the ClassLoader Maze" instead.
Note that two conditional compilation constants control
loadProperties() behavior, and you can tune them to suit your tastes:
loadProperties()throws an exception or merely returns
nullwhen it can't find the resource
LOAD_AS_RESOURCE_BUNDLEselects whether the resource is searched as a resource bundle or as a generic classpath resource
true isn't advantageous unless you want to benefit from localization support built into
java.util.ResourceBundle. Also, Java internally caches resource bundles, so you can avoid repeated disk file reads for the same resource name.
I intentionally omitted an interesting classpath resource loading method,
ClassLoader.getResources(). Despite its infrequent use,
ClassLoader.getResources() allows for some very intriguing options in designing highly customizable and easily configurable applications.
I didn't discuss
ClassLoader.getResources() in this article because it's worthy of a dedicated article. As it happens, this method goes hand in hand with the remaining
way to acquire resources:
java.net.URLs. You can use these as even more general-purpose resource descriptors than classpath resource name strings. Look for more
details in the next Java Q&A installment.
Read more about Core Java in JavaWorld's Core Java section.
|Forum migration complete By Athen|
|Forum migration update By Athen|
|A much smarter way to load properties and onfig By Bruce Conrad|
|Small inconvenience with classpath By Catalin|
|Loading properties from a static context By Anonymous|
|Smartly load your properties (nice Artical) By ihab|
|Consider using Jakarta Commons - Configuration By mortenhattesen|
|Bad exception handling, again By Anonymous|
|Issue loading properties file in an EAR By Prashant_Basawa|
|Toolbox stuff By rodney_draziw|
|ClassPath conflict By Anonymous|
|A property file in WEB-INF folder By lKamal99|
|Multi-user, multi-properties By Anonymous|