• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

How to parse a properties file with context markerrs

 
Greenhorn
Posts: 9
Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java supports Properties files and makes them easy to read.

Is there a way to easily parse a file that has properties grouped into contexts
[100]
user=Ron
city=Montreal
[101]
user=Mary
city=New York
[102]
user=Jacques
city=Paris

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That format looks like the format that is used in Windows *.ini files. Java's java.util.Properties class doesn't support this. So if you want to parse a file in that format, you'd have to write some code yourself for that.
 
Ron Wheeler
Greenhorn
Posts: 9
Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks

That was the nudge that I needed. Feel a bit stupid that I did not make the relation to the INI format.

A quick google got me
http://stackoverflow.com/questions/190629/what-is-the-easiest-way-to-parse-an-ini-file-in-java

which has a link to

http://ini4j.sourceforge.net/index.html

Looks like it will move me forward to the next blockage!

Ron
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic