To fetch a ResourceBundle object, use the Java ResourceBundle.getBundle method. This method instantiates a ResourceBundle object for the specified ResourceBundle basename and locale. After using the getBundle method to instantiate the object, use the getObject or getString method to retrieve the value from the specified property in the given ResourceBundle object.

The ResourceBundle that is instantiated depends on the files that exist for the given basename. If a file does not exist for the specified basename and locale arguments, the locale of the returned ResourceBundle depends on the ResourceBundle inheritance rules. See the ResourceBundle Inheritance topic in this chapter for more information.


For example, you can create a ResourceBundle with a base name of DynamoBundle and the current request locale as follows:

resourceA = ResourceBundle.getBundle ("atg.dynamo.DynamoBundle",

If the current request locale is de_DE, a DynamoBundle object is created from the file. If this file does not exist, the next best .properties file is used, according to the ResourceBundle inheritance rules.

To retrieve the price label string from the DynamoBundle ResourceBundle, you specify the appropriate key from the DynamoBundle when invoking the getString method:

String PriceLabel = resourceA.getString ("PriceKey");

This method retrieves the PriceKey value from the instantiated DynamoBundle object.

Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices