Yesterday in a project, an additional properties file needs to be read, and the properties file is stored in the Maximo/properties folder. First, read the installation path of Maximo. Of course, this is the most critical step.
Thanks to the hello. Class. getprotectiondomain (). getcodesource (). getlocation (). GetFile () method provided by fedora Maximo (438658902. Now let's testCodePost it:
String loctemp = cumractionappr2yg. class. getprotectiondomain (). getcodesource (). getlocation (). getFile (); string maximoaddress = loctemp. substring (1, loctemp. lastindexof ("Maximo"); properties prop = new properties (); inputstream in = NULL; try {In = new bufferedinputstream (New fileinputstream (maximoaddress + "properties/ygjk. properties "); prop. load (in); fmisaddress = prop. getproperty ("FMIS. address. IP "). tr Im (); system. out. println ("fmisaddress: >>>" + fmisaddress);} catch (filenotfoundexception E1) {e1.printstacktrace (); throw new mxapplicationexception ("prompt #", "the configuration file does not exist, contact the administrator. ");} Catch (ioexception e) {e. printstacktrace (); throw new mxapplicationexception (" prompt # "," An error occurred while reading the configuration file. Please contact the administrator. ");} Finally {If (in! = NULL) {try {in. Close ();} catch (ioexception e) {e. printstacktrace ();}}}
During the exploration, we found that Maximo had a method to read the configuration file:
String temppro = mxserver. getmxserver (). getproperty ("FMIS. address. IP "); system. out. println (">>>>>>>>>" + temppro );
However, it seems that this method can only read the configuration in Maximo. properties that comes with Maximo. The key-value added by myself cannot be read. This will take some time to explore...