参数文件
引用
qnr.properties 之中属性:exportURL=http://ww...
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");