Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

which is worse Prop file or XML  RSS feed

 
Dinesh Bang
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
which one out of the following, takes more time :
1. Reading a value from property file
OR
2. Reading from teh XML file ?
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are few definite answers in performance. It so often depends on context.

Generally, though, I'd expect properties to be faster than XML. The properties file format is simpler. Parsing it doesn't have as much set-up as parsing XML.

It would rarely be appropriate to base your design decision on this, though. Normally, choosing between properties and XML would depend on what types of system or person were going to be producing and consuming these files. For instance, properties is a Java-specific thing, whereas XML is universal. Also, XML is better at structured (particularly hierarchical) data, while properties is more for flat data.

Why is performance an issue for reading these files? Are you reading lots of them? Are you reading the same file frequently? If the latter, can you use caching?

Finally, your login name is a bit borderline for JavaRanch. We require at least two names (*not* initials) and they must be, or at least sound like, a real name. As it's borderline, that's all I'm saying, but changing your display name to something better would be appreciated. Later: I have been corrected - we do allow initials, though full names remain preferred.
[ July 03, 2007: Message edited by: Peter Chase ]
 
Jaspreet Singh Puri
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would agree that performance wise File reading would be better. But file has its limitation like validation etc can not be forced.

I have come across few projects where jaxb can be used to load the xml as java object which can be useful. An xml file can be validated against the xsd and hence provide a better solution
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!