Code
Package Com. vmm. config;
Import Java. Io. ioexception;
Import Java. Io. inputstream;
Import Java. util. properties;
Public Class Config {
Private Static String config_file_path = " /Config. Properties " ;
Private Static Config inst;
Private String IP;
Private Int Port;
Private Config (){
Init ();
}
Public Static Config getinstance (){
If (Inst = Null ){
Inst = New Config ();
}
Return Inst;
}
Private Void Init (){
System. Out. println ( " Init ////////// " );
Inputstream in = Getclass (). getresourceasstream (config_file_path );
Properties pro = New Properties ();
Try {
Pro. Load (in );
In. Close ();
} Catch (Ioexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
IP = Pro. getproperty ( " IP " );
Port = Integer. parseint (PRO. getproperty ( " Port " ));
}
Public String getip (){
Return IP address;
}
Public Int Getport (){
Return Port;
}
}
Set config. properties to the SRC root directory.