Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30550
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2014-12-12 08:40 -0800 |
| References | <c12651b9-38b4-4604-9084-4bfd2aa0ba86@v31g2000vbs.googlegroups.com> |
| Message-ID | <ff033a1b-8b72-4292-b12a-90d868bf43a7@googlegroups.com> (permalink) |
| Subject | Re: Reading a properties file so that keys can be retrieved in order |
| From | etienne.studer@gradleware.com |
On Thursday, May 12, 2011 9:53:59 PM UTC+2, laredo...@zipmail.com wrote:
> Hi,
>
> I'm using Java 1.6. Let's say I have a properties file ...
>
> a=1
> b=2
> c=3
> ...
>
> How can i read the properties file in Java such that when I retrieve
> the key set, the iterator structure would return the keys in the order
> they are found in the file (in the above example, "a", "b", "c")?
>
> Thanks, - Dave
See https://github.com/etiennestuder/java-ordered-properties for a complete implementation that allows to read/write properties files in a well-defined order.
OrderedProperties properties = new OrderedProperties();
properties.load(new FileInputStream(new File("~/some.properties")));
The OrderedProperties class will solve your requirement.
Kind regards, Etienne
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Reading a properties file so that keys can be retrieved in order etienne.studer@gradleware.com - 2014-12-12 08:40 -0800
Re: Reading a properties file so that keys can be retrieved in order Arne Vajhøj <arne@vajhoej.dk> - 2014-12-12 19:02 -0500
Re: Reading a properties file so that keys can be retrieved in order Robert Klemme <shortcutter@googlemail.com> - 2014-12-16 13:14 +0100
csiph-web