Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

Difference Between ResourceBundle and Properties Classes in Java

Thread view: 
GMHK - 24 Jun 2005 12:35 GMT
Hi,

Can anyone tell me the whats the difference between the resource bundle
and Properties classes in java.
As both uses the .properties file  to get the string constants.
At what point of time would the programmer decide to choose which of
the either classes.
What i understood so far is resourcebundle makes uses of String manager
to get the string.
where as the Properties tries to read the properties directly.

Thanks in Advance
Thomas Weidenfeller - 24 Jun 2005 13:05 GMT
> Can anyone tell me the whats the difference between the resource bundle
> and Properties classes in java.
> As both uses the .properties file  to get the string constants.

No, they don't necessarily. A resource bundly does not have to be
file-based. The common implementation, however is. And that common
implementation (PropertyResourceBundle) indeed uses properties files and
thr Properties class.

However, resource bundles also come with a particular lookup-schema to
select a particular bundle according to the Locale. Something which you
don't get with Properties, but which is important when you do some
actual localization.

> At what point of time would the programmer decide to choose which of
> the either classes.

A resource bundle (properties file based or otherwise) when in need for
the lookup of locale-specific data. A naked properties file when in need
for keeping some small (FSWO) set of data persistent (e.g. application
configuration data), which is not supposed to be translated.

You didn't mention Preferences. I still preferen Properties over
Preferences because of the easy-to-work-with text file format, but they
can be used for the same purpose as Properties, without the need of
having to deal with files.

> What i understood so far is resourcebundle makes uses of String manager
> to get the string.
> where as the Properties tries to read the properties directly.

Both map keys to values. The biggest difference is how they get that
mapping. ResourceBundles follow a build-in lookup schema taking a locale
into account. Properties need to be provided with some InputStream,
which the programmer has to handle explicitely. Properties have an easy
way to be written to an OutputStream, while ResourceBundles are ment to
be read-only.

/Thomas

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.