Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Difference Between ResourceBundle and Properties Classes in Java

Reply
Thread Tools

Difference Between ResourceBundle and Properties Classes in Java

 
 
GMHK
Guest
Posts: n/a
 
      06-24-2005
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

 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      06-24-2005
GMHK wrote:
> 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


--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
 
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading a properties file using ResourceBundle khanhly via JavaKB.com Java 1 08-16-2006 08:41 PM
ResourceBundle can't find properties file unless in package charles.hajj@gmail.com Java 6 04-26-2006 07:28 PM
Urgent: Resourcebundle.getBundle() doesn't look for properties file Ramkumar Kaleeswaran Java 3 12-08-2005 12:03 PM
difference between java built in classes and ADT Kenneth Java 4 11-11-2004 08:11 AM
ResourceBundle.getBundel - absolute Path to .properties Markus Java 1 02-12-2004 09:44 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57