• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get the values from a properties file in the insertion order?  RSS feed

 
sanjeev katthi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to get the values from a properties file in the insertion order? please reply me...
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If by that you mean the order in which they are in the file, then you could open the it using regular file I/O, and read it in your code instead of using the Properties class. It shouldn't be hard to make a clone of the Properties class that uses a List instead of a Map (and thus preserves the order in which entries are read).
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A LinkedHashMap<String, String> would be a good replacement for Properties if you want a Map that remembers the order the elements were read in. You'd need to write a replacement for the load() method, but that's not too hard. You may be able to skip some of the features allowed in Properties files, like escape sequences for non-ASCII characters, or continued lines. Those aren't too complex anyway, but you can keep things simple if you want to.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!