The difference between ResourceBundle and Properties classes

xiaoxiao2021-03-06  45

In general, the ResourceBundle class is usually used for properties files for use in different languages.

And if the properties file in your application is just some configurations, it is not for the purpose of multi-language. Then you can use the Properties class.

These attribute files can usually be placed in a JAR file. Then, by calling the Class's getResourceAsStream method, the stream of the property file is obtained, and the LOAD method of the Properties class is loaded.

Examples are as follows:

Class testload {

Public static void main (string [] argv) {

InputStream IS = Testload.class.getResourceceassteham ("MyProps.properties");

Properties P = new profment ();

p.Load (IS);

System.out.println (p.get ("mail_server_hostname));

}

}

转载请注明原文地址:https://www.9cbs.com/read-45324.html

New Post(0)