Project properties File Processing Method class, properties Processing Method

Source: Internet
Author: User

Project properties File Processing Method class, properties Processing Method

Function: load the properties file and obtain the value of the key.

1 import java. util. resourceBundle; 2 3/** 4 * properties File Processing Method class 5 */6 public class ConfigHolder {7 private static ResourceBundle bundle; 8 9/** 10 * load the properties file 11 */12 private static void loadConfig () {13 if (bundle = null) {14 // config is available under the class. properties file. If it is under a certain package, it is like: ort. config15 bundle = ResourceBundle. getBundle ("config "); 16} 17} 18 19/** 20 * Get the specified key value in the properties file 21 * @ param key22 * @ return23 */24 public static String getValue (String key) {25 loadConfig (); 26 return bundle. getString (key); 27} 28}

 

Related Article

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.