📄 propsutil.java
字号:
package com.jdon.util;
import java.io.*;
import java.util.*;
import java.net.URL;
import com.jdon.util.jdom.*;
import org.apache.log4j.Logger;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Jdon.com Copyright (c) 2003</p>
* <p>Company: </p>
* @author banq
* @version 1.0
*/
public class PropsUtil {
public final static String module = PropsUtil.class.getName();
public final static String XML_CONFIG_FILE = "config.xml";
public final static String LOG = "log.level";
public final static String LOG4J = "log.log4j";
public final static String SETUPNAME = "setup";
public final static String SETUPVALUE = "true";
public static String ENCODING = "UTF-8";
private Map propMap = new HashMap();
private FileLocator fileLocator = new FileLocator();
private final static PropsUtil propsUtil = new PropsUtil();
public static PropsUtil getInstance() {
return propsUtil;
}
/**
* load default config file
*/
private PropsUtil() {
loadProperties(XML_CONFIG_FILE);
}
public void loadProperties(String configName) {
System.out.println(" load basic configure file " + configName);
InputStream pathCongfgName = getConfStream(configName);
if (pathCongfgName != null) {
XMLProperties properties = new XMLProperties(pathCongfgName);
propMap.put(configName, properties);
return;
}
InputStream stream = getConfStream(configName);
if (stream != null) {
XMLProperties properties = new XMLProperties(stream);
propMap.put(configName, properties);
return;
}
System.err.println(" cann't load config file:-->" + configName);
}
public String getConfFile(String fileName) {
return fileLocator.getConfFile(fileName);
}
public InputStream getConfStream(String fileName) {
return fileLocator.getConfStream(fileName);
}
public String getProperty(String name) {
return getProperty(XML_CONFIG_FILE, name);
}
public String getProperty(String configName, String name) {
XMLProperties properties = (XMLProperties) propMap.get(configName);
String res = properties.getProperty(name);
if (res == null)
res = "";
return res;
}
public void setProperty(String name, String value) {
setProperty(XML_CONFIG_FILE, name, value);
}
public void setProperty(String configName, String name, String value) {
XMLProperties properties = (XMLProperties) propMap.get(configName);
properties.setProperty(name, value);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -