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