BAEL-923 How to inject a value from properties to a class not managed by Spring? (#1878)
* adam.zawada@gmail.com - Different Types of Bean Injection in Spring * adam.zawada@gmail.com - Different Types of Bean Injection in Spring switch to Java based configuration * BAEL-895 calculate the period/duration between two dates in Java 8 * clean old PR * BAEL-923 How to inject a value from properties to a class not managed by Spring? * clean PR
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.baeldung.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class PropertiesLoader {
|
||||
|
||||
public static Properties loadProperties(String resourceFileName) throws IOException {
|
||||
Properties configuration = new Properties();
|
||||
InputStream inputStream = PropertiesLoader.class
|
||||
.getClassLoader()
|
||||
.getResourceAsStream(resourceFileName);
|
||||
configuration.load(inputStream);
|
||||
inputStream.close();
|
||||
return configuration;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user