读取:
public class PropertiesConfig {
private static Properties prop;
static
{
prop = new Properties();
// 从属性配置文件中读取配置参数
try
{
InputStream resource = PropertiesConfig.class.getResourceAsStream("/db.conf");
System.out.println(resource);
prop.load(resource);
resource.close();
} catch (java.io.IOException e)
{
e.printStackTrace();
System.out.println("Could not read list of ages");
}
}
/**
*
* @返回参数属性集
*/
public Properties getProperties(){
return prop;
}}
2.调用:
private String userNaming ;
public Show_Areainfo(){
Properties prop=new PropertiesConfig().getProperties();
userNaming=prop.get("service").toString();
}
929wyt.com http://se.sao49.com/