import java.util.Enumeration;
import java.util.Locale;
import java.util.ResourceBundle;
class ResourceBundleApp {
public static void main(String args[]) {
if (args.length != 1) {
System.out.println("Usage: java ResourceBundleApp country_code");
System.exit(0);
}
Locale mexico = new Locale("es", "MX");
Locale spain = new Locale("es", "ES");
Locale locales[] = { mexico, spain, Locale.US, Locale.CANADA, Locale.UK };
Locale newLocale = null;
for (int i = 0; i < locales.length; ++i) {
if (args[0].equals(locales[i].getCountry())) {
newLocale = locales[i];
break;
}
}
if (newLocale == null) {
System.out.println("Country not found.");
System.exit(0);
}
ResourceBundle resources = ResourceBundle.getBundle("TextBundle", newLocale);
Enumeration e = resources.getKeys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
System.out.println(resources.getString(key));
}
}
}