Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Certification
»
Programmer Certification (OCPJP)
Internationalization
Enkita mody
,
Ranch Hand
Oct 08, 2012 00:27:43
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
import java.util.*; public class PropertiesDemo { static void displayValue(Locale currentLocale, String key) { ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle",currentLocale); String value = labels.getString(key); System.out.println( "Locale = " + currentLocale.toString() + ", " + "key = " + key + ", " + "value = " + value); } // displayValue static void iterateKeys(Locale currentLocale) { ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle",currentLocale); Enumeration bundleKeys = labels.getKeys(); while (bundleKeys.hasMoreElements()) { String key = (String)bundleKeys.nextElement(); String value = labels.getString(key); System.out.println("key = " + key + ", " + "value = " + value); } } // iterateKeys static public void main(String[] args) { Locale[] supportedLocales = { Locale.FRENCH, Locale.GERMAN, Locale.ENGLISH }; for (int i = 0; i < supportedLocales.length; i ++) { displayValue(supportedLocales[i], "s2"); } System.out.println(); iterateKeys(supportedLocales[0]); } // main } // class # This is the default LabelsBundle.properties file s1 = computer s2 = disk s3 = monitor s4 = keyboard # This is the LabelsBundle_de.properties file s1 = Computer s2 = Platte s3 = Monitor s4 = Tastatur # This is the LabelsBundle_fr.properties file s1 = Ordinateur s2 = Disque dur s3 = Moniteur s4 = Clavier
I couldn't figure out, where was the use of PropertyResourceBundle class here ?
Post by:
autobot
We don't have time for this. We've gotta save the moon! Or check this out:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
This thread has been viewed 801 times.
Similar Threads
is getting me confused
SCEA Question about ResourceBundle: What is your answer?
== with Strings is giving a different result
String and String Object Problem
Strings
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:15:02
.