Hi guys I am having problems with writing on a properties file. The properties file can be loaded without any problem and the key value can be changed but after I have store it with a fileoutoutstream it seems it did its job but there is no change on the properties file.
Resource resource = new ClassPathResource("application.properties");
Properties props = PropertiesLoaderUtils.loadProperties(resource);
props.setProperty("image.path", "empty");
OutputStream propOut = new FileOutputStream(new File("application.properties"));
props.store(propOut, "User change");
propOut.close();
I am trying it in a Spring project. The 开发者_如何学JAVAfile application.properties cannot be changed and there is no error so I can have any clue about the problem.
What do you think I am missing? Any help will be much appreciated. Cheers
You have to store the properties as follows:
props.store(resource.getOutputStream(), "comments");
精彩评论