Which Bundle Comes First
import java.util.ResourceBundle;
import java.util.MissingResourceException;
public class WhichBundleComesFirstExample {
public static void main(String [] argv) {
try {
ResourceBundle resources = ResourceBundle.getBundle("WhichBundleComesFirstResources");
System.out.println(resources.getString("Message3"));
System.out.println(resources.getString("Message2"));
System.out.println(resources.getString("Message1"));
} catch (MissingResourceException mre) {
mre.printStackTrace();
}
}
}
///////
/*import java.util.ListResourceBundle;
public class WhichBundleComesFirstResources extends ListResourceBundle {
public Object [][] getContents() {
return contents;
}
static final Object [][] contents = {
{"Message1", "Message 1: From WhichBundleComesFirstResources (ListResourceBundle)"}
};
}
*/
import java.util.ListResourceBundle;
public class WhichBundleComesFirstResources extends ListResourceBundle {
public Object [][] getContents() {
return contents;
}
static final Object [][] contents = {
{"Message1",
"Message 1: From WhichBundleComesFirstResources (ListResourceBundle)"}
};
}
//WhichBundleComesFirstResources.properties
# Properties file for WhichBundleComesFirst
#
# English language in the United States
#
Message1=Message 1: From WhichBundleComesFirstResources (Properties file)
//WhichBundleComesFirstResources_en.properties
/*
# Properties file for WhichBundleComesFirstResources_en
#
# English language in the United States
#
Message2=Message 2: From WhichBundleComesFirstResources_en (Properties file)
*/
import java.util.ListResourceBundle;
public class WhichBundleComesFirstResources_en_US extends ListResourceBundle {
public Object [][] getContents() {
return contents;
}
static final Object [][] contents = {
{"Message3", "Message 3: From WhichBundleComesFirstResources_en_US (ListResourceBundle)"}
};
}
//WhichBundleComesFirstResources_en_US.properties
/*
# Properties file for WhichBundleComesFirstResources_en_US
#
# English language in the United States
#
Message3=Message 3: From WhichBundleComesFirstResources_en_US (Properties file)
*/
Related examples in the same category