Properties file tool class, properties tool class
Package xxx. business. utils; import org. apache. commons. configuration. configurationException; import org. apache. commons. configuration. propertiesConfiguration; import org. apache. commons. configuration. reloading. fileChangedReloadingStrategy; import org. slf4j. logger; import org. slf4j. loggerFactory;/*** Created by windwant on 2016/7/19. */public class ConfigUtils {private static final Logger logger = LoggerF Acloud. getLogger (ConfigUtils. class); private static PropertiesConfiguration config = null; static {try {if (config = null) {config = new PropertiesConfiguration ("config. properties "); // automatically reload config. setReloadingStrategy (new FileChangedReloadingStrategy (); // automatically save config. setAutoSave (true) ;}} catch (ConfigurationException e) {logger. error ("load config. properties error ", e); throw new RuntimeE Xception (e) ;}} private ConfigUtils () {} public static String get (String key) {if (config! = Null) {String value = config. getString (key); return value = null? "": Value;} return "";} public static Integer getInteger (String key) {int result =-1; if (config! = Null) {try {result = Integer. parseInt (config. getString (key);} catch (NumberFormatException e) {result =-1 ;}} return result ;}}