Hi Hani

java.util.ResourceBundle is an abstract class:
-- It's static method "getBundle( String baseName )" returns a 
ResourceBundle instance corresponding to the requested "baseName".
-- The ResourceBundle object helps you obtain a resource Object or 
String by its name, using "getObject( String key )" or, respectively 
"getString( String key )".
-- You can get different answers according to current Locale (or you may 
specify a different Locale as an argument to "getBundle(...)" static method)

This was how to /use/ it in your application. In order to be able to use 
it, you must /implement/ it in your application too:
-- Either you create a ResourceBundle derived class to store your 
resource information and to dispatch resource objects by name
-- Or you create one or more ".properties" files (one per each available 
Locale plus one to be used by default) and Java creates a ResourceBundle 
for you, letting to access the items in the ".properties" file(s). In 
this case, only String objects can be stored (contrary to an explicite 
ResourceBundle class that can return any kind of object, a Locale 
dependent Image for example).

In two words: ResourceBundle is a mechanism that allows you to 
manipulate various Locale-dependent application resources. If the 
resources are stored in ".properties" files, than the ResourceBundle 
acts as a wrapper.

java.util.Properties is a non-abstract class that is a direct wrapper to 
a ".properties" file, allowing to load it into memory, to obtain the 
stored String items by name, to modify the String for a given key and to 
save it back, independently from the default or required Locale. It is 
the most fitted way to manage application configuration (as long as it 
is stored as ".properties" and not as the nowaday fashionable "xml") - 
allowing to save user-specific settings (for e.g.).

So, if you need something like a recipice for language (locale) 
dependent application resources (such as message strings, but also 
colors, images, and so on), use the "ResourceBundle" mechanism, 
optionally based on ".properties" files (the alternative is explicite 
class returning the localized non-String resource objects). The 
application can read (and use) Resource objects but cannot modify them.

On contrary, if you need to manage application configuration, you can 
optionally use a ".properties" file (the alternative is an ".xml" file) 
and, in this case, use the "Properties" mechanism. The application can 
read (and use) properties and modify and save the modifications too. I 
once found somewhere some philosophy about how to manage general 
application default settings and user specific settings in the same 
application using "Properties" (better fitted for that than 
"ResourceBundle"s).

Hope it helps
mihai

Hani KSD a écrit :
> Hi,
>  
> Can anyone tell me the difference between ResourceBundle and Property 
> class.
>  
> I have used  ResourceBundle to load property from .properties file.
>  
> Regards,
> Hani
> -- 
> You received this message because you are subscribed to the Google
> Groups "Java EE (J2EE) Programming with Passion!" group.
> To post to this group, send email to
> java-ee-j2ee-programming-with-passion@googlegroups.com
> To unsubscribe from this group, send email to
> java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en
>  

-- 
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en

Reply via email to