作者:fst123 | 来源:互联网 | 2024-10-22 17:40
importjava.util.MissingResourceException;importjava.util.ResourceBundle;publicclassTest{
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Test {
//资源文件名
private static String CONFIGURATION_FILENAME = "gemplanet";
//想要取得的key
private static String KEY = "FileType";
public static void main(String[] args) {
String value = (String)getEnvironmentVariable(KEY);
System.out.println(value);
}
private static String getEnvironmentVariable(String key) {
try {
ResourceBundle bundle = ResourceBundle.getBundle(CONFIGURATION_FILENAME);
return bundle.getString(key);
} catch (MissingResourceException e) {
return null;
}
}
}