Properties prop = new Properties();
FileOutputStream oFile = new FileOutputStream("systemConfig.properties", true);
prop.setProperty("a", 1);
prop.store(oFile, "The New properties file");
oFile.close();
这样子没修改成功!文件路径也没报错
这样写试一下;
Properties prop = new Properties();
FileInputStream oFile = new FileInputStream("systemConfig.properties");
prop.load(oFile);
prop.setProperty("a", 1);
prop.store(new FileOutputStream("systemConfig.properties"), "The New properties file");
oFile.close();
编译都不过啊:
public Object setProperty(String key, String value)
路径问题:http://bbs.csdn.net/topics/390872205
request.getSession().getServletContext().getRealPath("/WEB-INF/classes/config/extranet.properties")
1:路径没有写对,需要写上classpath:*.*
2 : 如果你是用tomcat+IDE开发工具运行,并不会对你工具里面的配置文件进行修改,而是修改的tomcat里面的配置文件 。那个才是真正运行时候的配置文件。