Java ListResourceBundle.getKeys()
Syntax
ListResourceBundle.getKeys() has the following syntax.
public Enumeration <String> getKeys()
Example
In the following code shows how to use ListResourceBundle.getKeys() method.
//w ww . jav a 2s . c om
import java.util.*;
class MyResources extends ListResourceBundle {
protected Object[][] getContents() {
return new Object[][]{
{"hello", "from java2s.com"},
{"client", "HTML"},
{"server", "PHP"}
};
}
}
public class Main {
public static void main(String[] args) {
MyResources mr = new MyResources();
// get the keys
Enumeration<String> enumeration = mr.getKeys();
// print the keys
while (enumeration.hasMoreElements()) {
System.out.println(enumeration.nextElement());
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »