Java Utililty Methods Properties Load

List of utility methods to do Properties Load

Description

The list of methods to do Properties Load are organized into topic(s).

Method

voidloadProperties(String name, ClassLoader loader)
This will load the properties file in the current context into Properties.
if (name == null) {
    throw new IllegalArgumentException("null input: name");
if (name.startsWith("/")) {
    name = name.substring(1);
if (name.endsWith(SUFFIX)) {
    name = name.substring(0, name.length() - SUFFIX.length());
...
PropertiesloadProperties(String properties)
Loads a key/value pair string as Properties
Properties p = new Properties();
try {
    p.load(new StringReader(properties));
} catch (NoSuchMethodError e) {
    p.load(new ByteArrayInputStream(properties.getBytes()));
return p;
PropertiesloadProperties(String properties)
Load properties from string.
Properties p = new Properties();
p.load(new StringReader(properties));
return p;
PropertiesloadProperties(String propertyName)
Loads a properties file in the startup directory
Properties props = new Properties();
File file = new File(propertyName);
FileInputStream fis = null;
if (file.exists()) {
    fis = new FileInputStream(file);
    props.load(fis);
} else {
    props = null;
...
PropertiesloadProperties(String resource)
load Properties
Properties props = new Properties();
fillProperties(props, resource);
return props;
PropertiesloadProperties(String resourceName)
Reads the given properties file.
return loadProperties(streamForFile(resourceName));
PropertiesloadProperties(String resourceName, ClassLoader classLoader)
Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the given class loader.
Properties props = getCachedProperties(resourceName);
if (props != null)
    return props;
Enumeration<URL> urls = classLoader.getResources(resourceName);
props = new Properties();
while (urls.hasMoreElements()) {
    URL url = urls.nextElement();
    URLConnection con = url.openConnection();
...
PropertiesloadPropertiesFromResource(ClassLoader clsLoader, String resourcePath)
Load properties from a resource embedded in the classpath.
URL propURL = clsLoader.getResource(resourcePath);
if (propURL == null) {
    throw new IllegalStateException("Couldn't find properties " + resourcePath);
Properties properties = new Properties();
try {
    InputStream in = propURL.openStream();
    try {
...
PropertiesloadPropertiesFromResource(String name)
load Properties From Resource
InputStream is = null;
try {
    is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
    return loadPropertiesFromStream(is);
} finally {
    try {
        is.close();
    } catch (Exception ignore) {
...
Properties[]loadPropertiesFromResources(Class cls, String[] resources)
load Properties From Resources
if (resources == null) {
    return null;
Properties[] result = new Properties[resources.length];
for (int i = 0; i < resources.length; i++) {
    result[i] = loadPropertiesFromResource(cls, resources[i]);
return result;
...