package pt.link.utils;

import java.io.InputStream;
import java.util.Properties;

public class UtilProperties {

	public static String getPropertyValue(String resourceName, String propertyName, Class clazz) throws RuntimeException {
		Properties properties = new Properties();
		
		InputStream inputStream =  clazz.getResourceAsStream("/"+resourceName);
		try {
			properties.load(inputStream);
			return properties.getProperty(propertyName);
		} catch (Exception e) {
			throw new RuntimeException("Error loading properties" , e);
		}
	}
	
	public static void setPropertyValue(String resourceName, String propertyName, String value, Class clazz) throws RuntimeException {
		Properties properties = new Properties();
		
		InputStream inputStream =  clazz.getResourceAsStream("/"+resourceName);
		try {
			properties.load(inputStream);
			properties.setProperty(propertyName, value);
		} catch (Exception e) {
			throw new RuntimeException("Error loading properties" , e);
		}
	}

}
