我们在项目中可以把一些属性配置到×××.properties中,比如数据库连接信息。现在问题来了,我的属性文件中有一些值是需要根据后台得到的数据来动态改变的,请问这个要怎么实现?java或者flex都行,谢谢。
人生最曼妙的风景,竟是内心的淡定与从容!
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文件读取
动态从后台获取
从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();
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文件读取