Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Reading a properties file so that keys can be retrieved in order Date: Tue, 16 Dec 2014 13:14:11 +0100 Lines: 35 Message-ID: References: <548b8203$0$294$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: individual.net vfbrdOKZElAcWxhI05gcRQqnCzN9fM8/7UYi/qvnLKlkp5QVg= Cancel-Lock: sha1:TdH/6raPPKGss5Krl8PG0DWPXnA= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 In-Reply-To: <548b8203$0$294$14726298@news.sunsite.dk> Xref: csiph.com comp.lang.java.programmer:30574 On 13.12.2014 01:02, Arne Vajh=C3=B8j wrote: > On 12/12/2014 11:40 AM, etienne.studer@gradleware.com wrote: >> OrderedProperties properties =3D new OrderedProperties(); >> properties.load(new FileInputStream(new File("~/some.properties"))); The input stream is not properly closed as far as I can see. >> The OrderedProperties class will solve your requirement. > > The question is 3.5 years old. Maybe it took him so long... I am more concerned with the usefulness of this approach. Properties=20 are simply unordered and I think no special semantic should be applied=20 to that order. This is fragile. If order is needed it is much better=20 to choose property names accordingly and this is also what most people=20 seem to do. foo.bar.name.2=3DWorld foo.bar.name.1=3DHello foo.bar.name.3=3D! If it gets fancier than that then maybe properties are not the proper too= l. Kind regards robert --=20 remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/