ResourceBundle: getString(String key) : ResourceBundle « java.util « Java by API






ResourceBundle: getString(String key)

 

import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class MainClass {
  public static void main(String args[]) throws Exception {
    ResourceBundle resources;

    try {
      resources = ResourceBundle.getBundle("MyData");
      System.out.println(resources.getString("Hi"));
    } catch (MissingResourceException mre) {
      System.err.println("MyData.properties not found");
    }
  }
}



//File: MyData.properties
/*
Hi = Hello World!
*/


//File: MyData_fr.properties
/*
Hi = Salut tout le monde!
*/
           
         
  








Related examples in the same category

1.ResourceBundle: getBundle(String baseName)
2.ResourceBundle: getBundle(String baseName, Locale locale)