Java ResourceBundle .getStringArray (String key)
Syntax
ResourceBundle.getStringArray(String key) has the following syntax.
public final String [] getStringArray(String key)
Example
In the following code shows how to use ResourceBundle.getStringArray(String key) method.
/*w w w . j a va 2 s. c om*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Locale;
import java.util.ResourceBundle;
public class Main {
public static void main(String[] args) {
ResourceBundle bundle = ResourceBundle.getBundle("hello", Locale.US);
Enumeration<String> keys = bundle.getKeys();
ArrayList<String> temp = new ArrayList<String> ();
for (Enumeration<String> e = keys; keys.hasMoreElements();) {
String key = e.nextElement();
if (key.startsWith("java2s")) {
temp.add(key);
}
}
String[] result = new String[temp.size()];
for (int i = 0; i < temp.size(); i++) {
result[i] = bundle.getString(temp.get(i));
}
System.out.println(Arrays.toString(result));
}
}
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »