0 0

如何按顺序把几个参数写入my.properties文件呢?5

如何按顺序把几个参数写入my.properties文件呢?
请教,现在读写都没问题,执行完方法store,就是数据就没顺序,变乱了
2009年3月20日 10:02

3个答案 按时间排序 按投票排序

0 0

public
class Properties extends Hashtable<Object,Object>

它是按照hash算法排序的,不能单单使用它来维持你要的想要的顺序

2009年3月20日 14:26
0 0

一种方法是自己继承Properties类,重写它的store()方法,自己内部用List存储
另一种方法用apache commons configuration的PropertiesConfiguration

		PropertiesConfiguration config = new PropertiesConfiguration("test.properties");
		config.setProperty("prop1", "#000000");
		config.setProperty("prop2", "#000000");
		config.setProperty("prop3", "#000000");
		config.setProperty("prop4", "#000000");
		config.setProperty("prop5", "#000000");
		config.save();

2009年3月20日 10:58
0 0

就是在my.properties属性值上加{0},{1}...这样的吧
然后在action里按照你的顺序赋给他就行了。。。。

2009年3月20日 10:39

相关推荐

Global site tag (gtag.js) - Google Analytics