In the Java project, some configuration parameters are saved in the property file, so that the original code can be guaranteed to change the property file directly.
Propertyparser.java
Package Com.discover.parse;import Java.io.file;import Java.io.fileinputstream;import java.io.inputstream;import java.util.properties;/** * @author Administrator * */public class Propertyparser { /** * @param args */ public static void Main (string[] args) { //TODO auto-generated Method Stub Properties Properties = new properties (); String name = PropertyParser.class.getResource (""). GetPath (); String Path = name + "Config.properties"; File File = new file (path); if (file.exists ()) { try{ inputstream fis = new FileInputStream (file); Properties.load (FIS); System.out.println (properties.getproperty ("IP")); Fis.close (); } catch (Exception e) { //Todo:handle Exception } } }
Config.properties
ip=127.0.0.1
Execute the program, the console prints out the results
Java Parsing Property files