📄 configure.java
字号:
package com.swing.game.crystal.utils;
import java.net.MalformedURLException;
import org.dom4j.DocumentException;
import java.util.Map;
import java.io.IOException;
import org.dom4j.io.SAXReader;
import org.dom4j.Document;
import org.dom4j.Element;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Iterator;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Configure {
private static String cfgFile = "./SimpleServer.cfg.xml";
private static Map properties = null;
// private static final Object lock = Configure.class;
public static String getProperty(String key) throws MalformedURLException,
DocumentException, IOException {
if (properties == null) {
properties = new HashMap();
SAXReader reader = new SAXReader();
Document document = reader.read(new File(cfgFile));
Element root = document.getRootElement();
List l = root.selectNodes("./Element");
for (Iterator iter = l.iterator(); iter.hasNext(); ) {
Element e = (Element) iter.next();
properties.put(e.attributeValue("key"), e.attributeValue("value"));
}
}
return (String)properties.get(key);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -