当前位置: 技术问答>java相关
读取属性一般用ResourceBundle,保存属性用什么呢?
来源: 互联网 发布时间:2015-08-15
本文导语: JDK中有没有可用的类?给个大致的提示:) | java.util.ResourceBundle 以下是节选自文档: Unlike other types of resource bundle, you don't subclass PropertyResourceBundle. Instead, you supply properties files containing...
JDK中有没有可用的类?给个大致的提示:)
|
java.util.ResourceBundle
以下是节选自文档:
Unlike other types of resource bundle, you don't subclass PropertyResourceBundle. Instead, you supply properties files containing the resource data. ResourceBundle.getBundle() will automatically look for the appropriate properties file and create a PropertyResourceBundle that refers to it. The resource bundle name that you pass to ResourceBundle.getBundle() is the file name of the properties file, not the class name of the object that is returned.
For example, if you say ResourceBundle.getBundle("MyResources", new Locale("fr", "FR")); the resource bundle lookup mechanism will search the class path for a file called MyResources_fr_FR.properties
以下是节选自文档:
Unlike other types of resource bundle, you don't subclass PropertyResourceBundle. Instead, you supply properties files containing the resource data. ResourceBundle.getBundle() will automatically look for the appropriate properties file and create a PropertyResourceBundle that refers to it. The resource bundle name that you pass to ResourceBundle.getBundle() is the file name of the properties file, not the class name of the object that is returned.
For example, if you say ResourceBundle.getBundle("MyResources", new Locale("fr", "FR")); the resource bundle lookup mechanism will search the class path for a file called MyResources_fr_FR.properties
|
ResourceBundle一般都是只读的,因为它的值可能影响其他的类,所以一般server启动后,这些值就不能变了。
而Properties也可以从InputStream, -D等方式中取出,作用于内存中,也就是说它允许你修改,但仅限于内存中,不能写到硬盘中。
而Properties也可以从InputStream, -D等方式中取出,作用于内存中,也就是说它允许你修改,但仅限于内存中,不能写到硬盘中。