📄 propertiesconfiguration.java
字号:
/* * WebWork, Web Application Framework * * Distributable under Apache license. * See terms of license at opensource.org */package webwork.config;import webwork.util.ClassLoaderUtils;import java.io.IOException;import java.net.URL;import java.util.Enumeration;import java.util.Iterator;import java.util.Properties;/** * Access configuration from a properties file. * * @author Rickard Öberg (rickard@middleware-company.com) * @version $Revision: 1.9 $ * */public class PropertiesConfiguration extends Configuration{ // Attributes ---------------------------------------------------- Properties settings; // Constructors -------------------------------------------------- public PropertiesConfiguration(String aName) { settings = new Properties(); URL settingsUrl = ClassLoaderUtils.getResource(aName+".properties", PropertiesConfiguration.class); if (settingsUrl == null) { throw new IllegalStateException(aName+".properties missing"); } // Load settings try { settings.load(settingsUrl.openStream()); } catch (IOException e) { throw new RuntimeException("Could not load "+aName+".properties:"+e); } } /** * Get a named setting. */ public Object getImpl(String aName) throws IllegalArgumentException { Object setting = settings.get(aName); if (setting == null) throw new IllegalArgumentException("No such setting:"+aName); return setting; } public void setImpl(String aName, Object aValue) { settings.put(aName, aValue); } public Iterator listImpl() { return settings.keySet().iterator(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -