Dark Horse programmer-Java configuration file

Source: Internet
Author: User

-------------------- Android training, Java training, and hope to communicate with you! ----------------------

I believe that people familiar with computers are no stranger to the word configuration files. configuration files are actually files that store computer software, systems, and other configuration information, by loading the configuration file at startup, you can obtain the information in the file to save the settings and modifications of the software system. The same functions are implemented in the Java configuration file.

The suffixes of common configuration files include properties and ini. Through the configuration file, we can achieve more flexible operations. The configuration file can be said to be an interface for implementing software and user interaction. For example, when we compile a source file into a binary file, we suddenly find that the class we operate in the source file cannot achieve the desired effect, so we need to find the source file again, modify it and then compile and run it. This is obviously inefficient. In this case, we can use the configuration file. The source file is operated by calling the class specified in the configuration file. When we need to change the class of the operation, we only need to modify the configuration file without modifying the source file and binary file, this obviously improves the efficiency. Let's take a look at the usage of the configuration file.

To use the configuration file, you must first understand a class properties, which is a subclass of hashtable, so it has the characteristics of a map set and stores strings in the form of key-value pairs.

You can use

 
Properties prop = new properties (); file F = new file ("specify the path of the configuration file here ");

Then

 
Prop. Load (New fileinputstream (f ));

Return Value: prop. getpropertis ("here is the key ");

Load configuration and obtain value, modify and use it

Prop. setpropertis ("modified key", "modified value ");

You can use

 
Prop. Store (New fileoutputstream (F), "here is the annotation information ");

This completes the configuration file operation.

I have heard that the configuration file is very useful, but I have not been very familiar with it yet. I can only say what I have come into contact, those that are not touched can only be experienced in future contacts.

 

-------------------- Android training, Java training, and hope to communicate with you! ----------------------
For details, see edu.csdn.net/heima.

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.