// Retrieve the content of a message in string format String message = bundle.getString("message.key"); System.out.println(message);
// Retrieve a message from a different locale Locale frenchLocale = new Locale("fr", "FR"); ResourceBundle frenchBundle = ResourceBundle.getBundle("messageBundle", frenchLocale); String message = frenchBundle.getString("message.key"); System.out.println(message);In this example, we create a Locale object for the French language and country, and retrieve the message bundle using that locale. The getString method is then used to retrieve a message from the French bundle. Package Library: java.util.ResourceBundle