Java ClassLoader load(String propsName)

Here you can find the source of load(String propsName)

Description

Load a properties file from the classpath.

License

Apache License

Parameter

Parameter Description
propsName a parameter

Exception

Parameter Description
Exception an exception

Return

Properties

Declaration

public static Properties load(String propsName) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.net.URL;
import java.util.Properties;

public class Main {
    /**/*from  ww w .  j av a  2  s  .  c o m*/
     * Load a properties file from the classpath. Thanks to: http://www.rgagnon.com/javadetails/java-0434.html
     *
     * @param  propsName
     *
     * @return  Properties
     *
     * @throws  Exception
     */
    public static Properties load(String propsName) throws IOException {

        Properties props = new Properties();
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        URL url = cl.getResource(propsName);
        props.load(url.openStream());

        return props;
    }
}

Related

  1. isExist(String path)
  2. isVMAlive(String procId)
  3. load(File propsFile)
  4. load(final String filename)
  5. load(String propertiesName)
  6. loadAttachApi()
  7. loadCorrectedConfiguration(String configurationFilename)
  8. loadFile(String file)
  9. loadGuiConfiguration(String configurationFilename)