Package Com.infofuse.util;import Java.util.missingresourceexception;import Java.util.resourcebundle;public class Propertiesutils {private static final String propertiesfile = "parameter"; Default binding resource private static resourcebundle resources = NULL; /** * Gets the specified property value * @param property name * @return */public static string Getpropertiesvalue (String Propert Y) {String val = ""; try {if (resources = = null) {initresources (); val = resources.getstring (property); } catch (Exception e) {//Ignore} return Val; /** * Gets the specified key value according to the configuration file * @param propertiesfile Properties File * @param property name * @return */Public St Atic string Getpropertiesvalue (String Propertiesfile, string property) { String val = ""; ResourceBundle resources1 = null; try {resources1 = Resourcebundle.getbundle (Propertiesfile); val = resources1.getstring (property); } catch (MissingResourceException e) {//Ignore} return Val; }/** * Initialize config file */private static void Initresources () {try {resources = ResourceBundle. Getbundle (Propertiesfile); } catch (MissingResourceException e) {throw new RuntimeException (e); } }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Tools Class (1) resourcebundle