Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java:PropertyResourceBundle_Java - Fatal编程技术网

Java:PropertyResourceBundle

Java:PropertyResourceBundle,java,Java,请帮我解释一下上面的代码…谢谢^我认为文档()对此解释得很好。另外,请查看资源束的概念。您可能有一组名为ManUtd.properties(默认语言)、ManUtd\u fr.properties(法语)、ManUtd\u de.properties(德语),(其他语言版本)等的文件。文件是一组键/值对;该类确保为当前对象使用适当的属性文件 在我看来,对属性资源bundle的转换是一件愚蠢的事情。应该是: public static String fnGetProperty(String ABC

请帮我解释一下上面的代码…谢谢^

我认为文档()对此解释得很好。另外,请查看资源束的概念。

您可能有一组名为
ManUtd.properties
(默认语言)、
ManUtd\u fr.properties
(法语)、
ManUtd\u de.properties
(德语),(其他语言版本)等的文件。文件是一组键/值对;该类确保为当前对象使用适当的属性文件

在我看来,对
属性资源bundle
的转换是一件愚蠢的事情。应该是:

public static String fnGetProperty(String ABC)
{
    PropertyResourceBundle configBundle = (PropertyResourceBundle)ResourceBundle.getBundle("ManUtd");
    return configBundle.getString(ABC);
}

使用代码
PropertyResourceBundle configBundle=(PropertyResourceBundle)ResourceBundle.getBundle(“ManUtd”)将在类路径上搜索名为ManUtd的ResourceBundle。基本上,如果您在系统中的某个位置有一个名为ManUtd.properties的文件,并且在运行程序时将该位置包含在类路径中(例如java-classpath“path/to/ManUtdFolder”),则会找到并加载该文件。

您不了解其中的哪一部分?
ResourceBundle configBundle = ResourceBundle.getBundle("ManUtd");