Java tutorial
import java.util.Enumeration; import java.util.HashSet; import java.util.Locale; import java.util.ResourceBundle; import java.util.Set; import java.util.StringTokenizer; class MainResourceBundle extends ResourceBundle { @Override public Object handleGetObject(String key) { if (key.equals("hello")) { return "Hello from java2s.com!"; } else { return null; } } @Override public Enumeration getKeys() { StringTokenizer key = new StringTokenizer("Hello from java2s.com!"); return key; } protected Set<String> handleKeySet() { return new HashSet<String>(); } } public class Main { public static void main(String[] args) { // create a new ResourceBundle with specified locale ResourceBundle bundle = MainResourceBundle.getBundle("hello", Locale.US); // print the keys Enumeration<String> enumeration = bundle.getKeys(); while (enumeration.hasMoreElements()) { System.out.println(enumeration.nextElement()); } } }