java中ResourceBundle的io查询
直接从这个API:
Otherwise, getBundle attempts to locate a property resource file using the generated properties file name. It generates a path name from the candidate bundle name by replacing all "." characters with "/" and appending the string ".properties". It attempts to find a "resource" with this name using ClassLoader.getResource.
它们对replacing all "." characters with "/"
意味着什么?举个例子吧?
附言:我同意追加。属性
# 1 楼答案
假设您有一个名为
包含名为
您必须指定以下任一项才能加载捆绑包
基本上,javadoc告诉您如何将传递给
getBundle
方法的参数转换为类路径上的资源。对我来说,默认的语言环境是en_US
,所以转化为
然后,它可以使用
ClassLoader
来查找该资源如果正确映射其名称,它返回的
ResourceBundle
实现实际上可能是一个自定义类。按照javadoc进行操作。否则,它只是一个Properties
资源包魔法发生在
ResourceBundle#newBundle(...)
这很简单