Java Read configuration File tool class
Using Java.util.Properties
Importjava.io.IOException;ImportJava.io.InputStream;Importjava.util.Properties; Public classPropertiesreader {Private StaticProperties prop; Static{reload (); } Private Static voidReload () {prop=NewProperties (); Try{InputStream InputStream= Propertiesreader.class. getClassLoader (). getResourceAsStream ("Config.properties"); Prop.load (InputStream); } Catch(IOException e) {e.printstacktrace (); } } /*** Gets the specified system attribute value * *@paramKey *@return */ Public Staticstring GetProperty (String key) {returnProp.getproperty (key); } /*** Gets the specified system attribute value (with default value) * *@paramKey *@paramDefaultValue *@return */ Public Staticstring GetProperty (String key, String defaultvalue) {returnProp.getproperty (key, DefaultValue); }}
Java Read Profile tool class (how to read values from properties file in Java)