java配置文件

来源:互联网 发布:arcgis js query post 编辑:程序博客网 时间:2024/06/06 18:16

1,工程中新建config.properties文本文件,放在web工程中的WEB-INF/classes 下即可 ,内容为键=值,可以用#来注释
如:

#teststest1=test1stest2=test2

2,读配置文件

public class test{InputStream in=test.class.getClassLoader().getResourceAsStream("config.properties");Properties pt=new Properties();pt.load(in);String stest1=pt.getProperty("stest1", "");String stest2=pt.getProperty("stest2", ");}

3,写入配置文件

。。。。 。。。。 pt.setProperty("键", "值");
原创粉丝点击