• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic