On 5 Aug 2003 06:58:55 -0700, iksrazal wrote:
[ResourceBundle vs. Properties]
Any clear rules on which method is best for particular situations?
The main purpose of a resource-bundle is localizing GUIs or
other things. The ResourceBundle-objects is trying to get the
appropriate file for a given Locale. Retrieving a value with
a ResourceBundle means that there is a value being expected
to be defined in a file. An exception will be thrown otherwise.
The main-purpose of a Properties-object is to keep key-value-pairs
with the ability to specify default-values when trying to retrieve
one. So this is mainly used for configuration-stuff. With that
you can write something for initializing a server:
ServerSocket ss = new ServerSocket(
Integer.parseInt(myProps.getProperty("server.port", "1234")));
So if the value is not set in the properties-file the default
1234 will be used. No exception will be thrown if there is
no value being set in a file, null will be returned instead.
The only advantage that might let somebody use ResourceBundle
instead of Properties is that ResourceBundle is getting throught
the CLASSPATH to get a bundle, but that can also be done with
a properties-file when using the getResourceAsStream-functionality
of a ClassLoader.
Regards, Lothar
--
Lothar Kimmeringer E-Mail: (e-mail address removed)
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
Always remember: The answer is forty-two, there can only be wrong
questions!