I just recently learned about the Properties class in java, and I’m trying to translate my old configuration file to be compatible with the Properties class. I want to know what would be the best way to setup a properties file for something like this:
Object type1
name obj1
age age1
Object type2
name obj2
age age2
I used spaces because I was using a Scanner to parse the file. I would create a List of Objects that stored the different objects and each Object had certain parameters with them, which I would get from the config file. So as I read along the file I would get the properties and create the object and store into my List.
I don’t want to use XML to create my properties file. I want something simple for a user to create and something that I could read easily in Java.
Any suggestions?
EDIT:
I want to try to get something with no need of numbering. For example in XML you can do something like this:
<table>
<fields>
<field>
<type>type1</type>
</field>
<field>
<type>type2</type>
<field>
</fields>
</table>
Obviously it would be easier to make a XML file like this, but I want to implement in a non-XML way.
The property keys ought to be unique. I’d suggest to use a numerical infix.
Then you can gather them in an incremental loop as follows:
Unrelated to the concrete problem, I am confident that XML is way much easier to maintain and parse, for example with JAXB.