Read the installation path of Maximo in the Code and read the properties file.

Source: Internet
Author: User

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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.