/** * Build a {@link ConfigPropertyProvider} using given <code>sourceFileName</code> as property source. * <p> * This method uses {@link ClassLoader#getResourceAsStream(String)} method to load the property stream, using the * same conventions to locate the resource to load. * </p> * @param sourceFileName Property file name * @param classLoader ClassLoader to use. If <code>null</code>, the default current classloader is used * @return ConfigPropertyProvider with given <code>sourceFileName</code> as property source. * @throws IOException File not found or read error */ static ConfigPropertyProvider using(String sourceFileName, ClassLoader classLoader) throws IOException { return using(ClassUtils.loadProperties(sourceFileName, classLoader, false)); }
/** * Load a {@link Properties} instance reading properties key/values from given file name. The file reference is * obtained using default (current thread or system) {@link ClassLoader}. * * <p> * See {@link ClassLoader#getResource(String)} for informations about file name resolution strategy. * </p> * * @param filename File name to read * @param lenient if <code>true</code>, when file is not found returns <code>null</code> without throwing any * exception * @return {@link Properties} instance containing all the properties read from file, if any * @throws IOException Error reading properties file */ public static Properties loadProperties(String filename, boolean lenient) throws IOException { return loadProperties(filename, ClassUtils.getDefaultClassLoader(), lenient); }
/** * Build a {@link ConfigPropertyProvider} using given <code>sourceFileName</code> as property source. * <p> * This method uses {@link ClassLoader#getResourceAsStream(String)} method to load the property stream, using the * same conventions to locate the resource to load. * </p> * @param sourceFileName Property file name * @param classLoader ClassLoader to use. If <code>null</code>, the default current classloader is used * @param lenient <code>true</code> to ignore source loading errors and return a provider with an empty set of * properties * @return ConfigPropertyProvider with given <code>sourceFileName</code> as property source. * @throws IOException File not found or read error */ static ConfigPropertyProvider using(String sourceFileName, ClassLoader classLoader, boolean lenient) throws IOException { return using(ClassUtils.loadProperties(sourceFileName, classLoader, lenient)); }