Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes How to parse a properties file with context markerrs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to parse a properties file with context markerrs" Watch "How to parse a properties file with context markerrs" New topic
Author

How to parse a properties file with context markerrs

Ron Wheeler
Greenhorn

Joined: Mar 20, 2012
Posts: 4

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

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Ron Wheeler
Greenhorn

Joined: Mar 20, 2012
Posts: 4

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
 
Consider Paul's rocket mass heater.
 
subject: How to parse a properties file with context markerrs