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");