/**
 * 
 */
package fr.univartois.bomberman.model.config;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * @author thibault
 *
 */
public class MyProperties implements Configuration{
	protected Properties prop=new Properties();
	public final static String PATH_CONFIG="/config/";
	
	
	private String path;

	
	public MyProperties(String path) {
		this.path=path;
		try {
			load();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void load() throws FileNotFoundException, IOException {
		prop.load(MyProperties.class.getResourceAsStream("/config/"+path));
	}

	public void save() throws FileNotFoundException, IOException {
		prop.store(new FileOutputStream(PATH_CONFIG+path),null);
		
	}

	public String get(String key) {
		return prop.getProperty(key);
	}
	
}
