public class Resourcesutils {/* * @description: Gets the file name based on the attribute * * @param:p The property name of the Ropertyname file * * @return: Returns the property value of the file * */p Ublic static string Getbyname (String propertyname) {String resultm = "";//return result ResourceBundle bundle = Resourcebundle.getb Undle ("config");//Gets the config familiar if (Bundle.containskey (PropertyName)) {//contains the attribute's key returns the corresponding value Resultm = bundle.getstring ( PropertyName);//Set return value}return Resultm;} /* * @description: Gets the file name according to the attribute * * @param:p The property name of the Ropertyname file * * @return: Returns the property value of the file * */public static String Getbyname (String propertyname, String propertyfile) {String Resultm = "";//Returns the result resourcebundle bundle = Resourcebundle.getbundle (propertyfile);//Gets the familiar if of config ( Bundle.containskey (PropertyName)) {//contains the property's key to return the corresponding value Resultm = bundle.getstring (propertyname);//Set return value}return Resultm;}}
Content in the configuration file:
Java background reading configuration file key and value-----Demo