Directly on the code:
Packagecom.base.jet.utils;Importjava.io.IOException;ImportJava.io.InputStream;Importjava.util.Properties; Public classPropertiesutils {PrivateProperties Properties; Private StaticPropertiesutils propertiesutils =Newpropertiesutils (); //private construction, prohibit direct creation Privatepropertiesutils () {Properties=NewProperties (); InputStream in= Propertiesutils.class. getClassLoader (). getResourceAsStream ("Config.properties"); Try{properties.load (in); } Catch(IOException e) {e.printstacktrace (); } } //get a single case Public Staticpropertiesutils getinstance () {if(Propertiesutils = =NULL) {propertiesutils=Newpropertiesutils (); } returnpropertiesutils; } //Server IP PublicString getserveripaddress () {returnProperties.getproperty ("Server.ipaddress"); } //Server Port PublicString Getserverport () {returnProperties.getproperty ("server. Port "); } //Whether it is debug mode PublicBoolean Getserverisdebug () {returnProperties.getproperty ("Server.isdebug"). Equals ("1")); } //password maximum number of errors Public intgetpwdrrrorcounts () {returnInteger.parseint (Properties.getproperty ("User.pwdrrrorcounts")); } //System version Number PublicString getsysversion () {returnProperties.getproperty ("Sys.version"); } Public Static voidMain (string[] args) {Propertiesutils Pro=propertiesutils.getinstance (); System.out.println ("/http" + pro.getserveripaddress () + ":" + pro.getserverport () + "/"); }}
Java Read Properties configuration file