package com.za.session.conf; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.Properties; public class ServerConfig { private String _configPath = "/com.za.session.properties"; private ServerProperty _prop = new ServerProperty(); private ServerConfig() { } public static ServerConfig instance() { return s_config; } public void init(String path) throws Exception { Properties p = new Properties(); java.io.File f = new java.io.File(path); String realPath = f.getAbsolutePath(); FileInputStream fis = null; try { fis = new FileInputStream(realPath); p.load(fis); this._prop.load(p); this._configPath = path; } finally { if (fis != null) fis.close(); } } public synchronized void resetProperties(ServerProperty prop) throws Exception { Properties p = new Properties(); this._prop.save(p); prop.save(p); java.io.File f = new java.io.File(this._configPath); String realPath = f.getAbsolutePath(); FileOutputStream fos = null; try { fos = new FileOutputStream(realPath); p.store(fos, "Base configuration of project sr_edu_base"); } finally { if (fos != null) fos.close(); } } public ServerProperty get_prop() { return this._prop; } private static ServerConfig s_config = new ServerConfig(); }