Here you can find the source of loadPropertiesFromClasspath( final String filename)
Parameter | Description |
---|---|
filename | - properties filename |
Parameter | Description |
---|---|
IOException | an exception |
null
static final Properties loadPropertiesFromClasspath( final String filename) throws IOException
//package com.java2s; import java.io.IOException; import java.util.Properties; public class Main { /**/*from ww w. j a va 2s . c o m*/ * Loads {@link Properties} using current thread's classloader. Here <i>filename</i> is supposed to be placed in * one of the roots which are covered by the default classpath of a webapp, e.g. <code>Webapp/WEB-INF/lib</code>, * <code>Webapp/WEB-INF/classes</code>, <code>Appserver/lib</code> or <code>JRE/lib</code>. If the properties file * is webapp-specific, best is to place it in <code>WEB-INF/classes</code>. If you're developing a project in an * IDE, you can also drop it in <code>src</code> folder (the project's source folder). * <p> * You can alternatively also put it somewhere outside the default classpath and add its path to the classpath of * the appserver. In for example Tomcat you can configure it as <code>shared.loader</code> property of * <code>Tomcat/conf/catalina.properties</code>. * * @param filename - properties filename * @return {@link Properties} object, never <code>null</code> * @throws IOException */ static final Properties loadPropertiesFromClasspath( final String filename) throws IOException { Properties properties = new Properties(); properties.load(Thread.currentThread().getContextClassLoader() .getResourceAsStream(filename)); return properties; } }