• Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting property file to object model  RSS feed

 
Kjeld Sigtermans
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Is there a nice way (e.g. some sort of framework) to convert/unmarshall/parse a textual property file to a object model?

I have a textual (not xml) property file with properties separated by dots like so:

Which I'd like to be converted to a Top instance having a Sub instance having two String keys:


Much like unmarshalling a XML document to a object model using JAXB...!

Anyone? Thanks!
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, and it's even built into java ...

http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html
 
Kjeld Sigtermans
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sebastian, thanks for your reply.

I mean an object model not just the key/value representation by java.util.Properties.
However, meanwhile I have found the method Properties.storeToXML(...) which exists since Java 1.5 which might do the trick. I hope it creates an XML representation which I can unmarshall. Trying this right now...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!