40 lines
1.4 KiB
Java
40 lines
1.4 KiB
Java
package IO;
|
|
|
|
/****************************************************LIBARIES***********************************************************/
|
|
//Java LIB
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import java.io.FileNotFoundException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.util.Properties;
|
|
|
|
/*******************************************************************************************************************
|
|
* Author: Ansgar [Hiajen]
|
|
* reverence: https://crunchify.com/java-properties-file-how-to-read-config-properties-values-in-java/
|
|
* Usage: Gibt Properties aus angegebenem Datei namen zurück
|
|
* state: done
|
|
*******************************************************************************************************************/
|
|
public class LoadProperties {
|
|
|
|
private Logger logger = LoggerFactory.getLogger(LoadProperties.class);
|
|
|
|
public Properties loadProperties(String propFileName){
|
|
logger.info("Load Properties: " + propFileName);
|
|
Properties prop = new Properties();
|
|
|
|
try (InputStream is = getClass().getClassLoader().getResourceAsStream(propFileName)){
|
|
prop.load(is);
|
|
} catch (FileNotFoundException e) {
|
|
logger.error(e.getMessage());
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
logger.error(e.getMessage());
|
|
}
|
|
|
|
return prop;
|
|
}
|
|
}
|