File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes XML vs Properties File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "XML vs Properties File" Watch "XML vs Properties File" New topic
Author

XML vs Properties File

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Which do you use for storing user settings, global settings, values, etc and why one over the other?


GenRocket - A Test Data Generation Platform
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
A properties file is much easier to use when you have a small, fixed set of settings with a plain structure.
An XML file implies more work, but is more appropriate to handle complex hierarchical settings.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
If you are comfortable with going for a simple solution first, and only adding extra complexity later if you really need it, then start with a Properties file (or, even bettter, a hard-coded Map).
As long as you have some sort of "facade" through which you access these settings, then it shouldn't matter to the calling code which one you use. Then you are free to use hard-coded default values, load from a properties file, read some XML, run a database query, look them up in a JNDI repository, access a web service etc. etc.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: XML vs Properties File
 
Similar Threads
Not to execute console based jdbc application
how to open .xls file in new window
A good, simple tutorial for making sockets work over the Internet.
Error while invoking SAPI with Java Script
Where is the Plugin Console?