MDi JLib
1.7.4

com.microdeveloper.util.io.property
Class PropertyLoader

java.lang.Object
  extended by com.microdeveloper.util.io.property.PropertyLoader

public abstract class PropertyLoader
extends Object

A Class used for loading properties by relative path using URL naming conventions.

Example usage:
PropertyLoader pl = PropertyLoader.loadProperties("com.microdeveloper.properties.myPropertyFile");

Portions credited to Vlad Roubtsov

Version:
1.0
Author:
(C) Gregg Lagnese, 2003

Method Summary
static Properties loadProperties(String name)
          A convenience overload of loadProperties(String, ClassLoader) that uses the current thread's context classloader.
static Properties loadProperties(String name, ClassLoader loader)
          Looks up a resource named 'name' in the classpath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadProperties

public static Properties loadProperties(String name,
                                        ClassLoader loader)
Looks up a resource named 'name' in the classpath. The resource must map to a file with .properties extention. The name is assumed to be absolute and can use either "/" or "." for package segment separation with an optional leading "/" and optional ".properties" suffix. Thus, the following names refer to the same resource:
 some.pkg.Resource
 some.pkg.Resource.properties
 some/pkg/Resource
 some/pkg/Resource.properties
 /some/pkg/Resource
 /some/pkg/Resource.properties
 

Parameters:
name - classpath resource name [may not be null]
loader - classloader through which to load the resource [null is equivalent to the application loader]
Returns:
resource converted to java.util.Properties [may be null if the resource was not found and THROW_ON_LOAD_FAILURE is false]

loadProperties

public static Properties loadProperties(String name)
A convenience overload of loadProperties(String, ClassLoader) that uses the current thread's context classloader. A better strategy would be to use techniques shown in http://www.javaworld.com/javaworld/javaqa/2003-06/01-qa-0606-load.html

Parameters:
name - relative properties file using package.class nomenclature
Returns:
properties object

MDi JLib
1.7.4

Copyright©2001-2007 MicroDeveloper, Inc. All Rights Reserved.