读书人

创造系统参数 (实例化参数)

发布时间: 2012-08-21 13:00:21 作者: rapoo

创建系统参数 (实例化参数)
参数文件
import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.util.Properties;public class SystemProperties {private Properties qnrSystemProperties = new Properties();private static SystemProperties context = null ;private SystemProperties() {}private void init(){initQnr();}private void initQnr() {String path = this.getClass().getResource("/").getPath()+ "qnr.properties";FileInputStream fin = null;try {fin = new FileInputStream(path);qnrSystemProperties.load(fin);fin.close();} catch (FileNotFoundException e1) {e1.printStackTrace();return;} catch (IOException e) {e.printStackTrace();return;}}public synchronized static SystemProperties getSystemPropertie(){if(context == null){context = new SystemProperties();context.init();}return context;}public String getQnrPropertyValue(String property){return qnrSystemProperties.getProperty(property);}}

引用
String updateURL = SystemProperties.getSystemPropertie()
.getQnrPropertyValue("exportURL");


读书人网 >Web前端

热点推荐