资源文件的读取

来源:互联网 发布:7723java游戏 编辑:程序博客网 时间:2024/05/16 09:55

1.DaoService

public class DAOService {
public static String getPatternConfigValue(String m1, String m2) {
String value = null;
try {
value = XMLParserFactory.getInstance()
.getConfigParserByInputStream().getValue(m1, m2);
} catch (Exception e) {
}

return value;
}

public static String getPropertiesValue(String key) {
String value = null;
try {
value=XMLParserFactory.getInstance().getPropertiesParserByInputStream().getPropValue(key);
} catch (Exception e) {
//System.out.println("��ȡ" + key + "�������쳣:" + e.getMessage());
}

return value;
}


2.PropertiesParser

public class PropertiesParser {
private static Properties props=null;

public PropertiesParser(InputStream in)
{
try {
props=new Properties();
props.load(in);
in.close();
} catch (Exception e) {
}
}

public String getPropValue(String key)
{
String value=null;
if(props!=null && key!=null)
{
value=props.getProperty(key);
}

return value;
}
}



原创粉丝点击