java - 如何动态修改属性文件×××.properties的某些内容
黄舟
黄舟 2017-04-17 13:00:09
0
3
882

我们在项目中可以把一些属性配置到×××.properties中,比如数据库连接信息。现在问题来了,我的属性文件中有一些值是需要根据后台得到的数据来动态改变的,请问这个要怎么实现?java或者flex都行,谢谢。

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
迷茫

http://crunchify.com/java-properties-file-how-to-read-config-properties-values-in-java/

洪涛

Why should the data that needs to be obtained dynamically be written in the properties file?
Just 动态从后台获取 is enough. These are two different configuration plans from 从properties文件读取

小葫芦
      // 读取配置文件
      FileInputStream inputStream = new FileInputStream(path);
      Properties prop = new Properties();
      // 加载
      prop.load(inputStream);
      // 获取
      prop.getProperty("key");
      // 设置
      prop.setProperty("key", "value");
      // 写到配置文件
      FileOutputStream outputStream = new FileOutputStream(path);
      prop.store(outputStream, "update message");
      outputStream.close();
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!