📄 genericutil.java
字号:
package com.ejsun.entapps.util;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Quake Wang
* @since 2004-5-1
* @version $Revision: 1.1 $
*
**/
public class GenericUtil {
private static final Log log = LogFactory.getLog(GenericUtil.class);
public static final String SIMPLEOA_HOME = "simpleoa.home";
public static final String ROOT_GROUP_NAME = "root.group.name";
public static final String ROOT_GROUP_ID = "root.group.id";
public static final String CONF_FILE = "simpleoa-conf.properties";
public static Properties loadConfProperties () {
URL url = UtilURL.fromFilename(getConfFilePath());
if(url != null) {
try {
Properties confProperties = new Properties();
confProperties.load(url.openStream());
return confProperties;
} catch (IOException e) {
log.error(e);
throw new IllegalStateException("loadConfProperties error: " + e);
}
}
return null;
}
public static Properties loadInitProperties() {
Properties init = new Properties();
try {
URL url = UtilURL.fromResource("simpleoa-init.properties");
if(url == null) throw new IllegalStateException("Can not find simpleoa-init.properties");
init.load(url.openStream());
} catch (IOException e) {
log.error(e);
throw new IllegalStateException("loadInitProperties error: " + e);
}
return init;
}
public static void storeRootGroupId(long rootGroupId) throws IOException, FileNotFoundException {
File confFile = new File(getConfFilePath());
Properties conf = new Properties();
conf.setProperty(ROOT_GROUP_ID, Long.toString(rootGroupId));
conf.store(new FileOutputStream(confFile), null);
}
private static String getConfFilePath() {
Properties p = loadInitProperties();
if(p.getProperty(SIMPLEOA_HOME) == null) {
log.warn(SIMPLEOA_HOME + " was not set, use default root path.");
return CONF_FILE;
} else {
return p.getProperty(SIMPLEOA_HOME) + CONF_FILE;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -