cz.jalasoft.util.configuration.provider.JavaPropertyConfigProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JalasoftUtils Show documentation
Show all versions of JalasoftUtils Show documentation
A collection of utility classes that might be useful.
The newest version!
package cz.jalasoft.util.configuration.provider;
import cz.jalasoft.util.configuration.source.ConfigSource;
import java.io.IOException;
import java.util.Properties;
/**
* @author Honza Lastovicka ([email protected])
* @since 2016-07-27.
*/
public final class JavaPropertyConfigProvider implements ConfigProvider {
private Properties properties;
@Override
public void reload(ConfigSource source) throws IOException {
properties = new Properties();
properties.load(source.load());
}
@Override
public String readProperty(String key) {
if (properties == null) {
throw new IllegalStateException("Call reload() first before readProperty().");
}
return properties.getProperty(key);
}
}