A Java properties file is used to store configuration data or settings for a Java project. .properties
is a file extension for files that store the configurable parameters of an application.
Recompilation is not required if modifications are made to a properties file.
If any information is changed in the properties file, the Java class does not need to be recompiled; hence, a properties file is usually used to store information that is frequently changed.
Each parameter is stored as a pair of strings; one string stores the name of the parameter and the other stores its value. These strings are similar to key-value pairs.
Suppose that there is a Java class that takes the username and password of a user along with the IP address of the server that the user wants to connect to. The properties file for this class will store the three parameters as:
username=Hassan
password=Educative_1331
ip_address=192.168.1.3
The program can now read these parameter values from this properties file.
Free Resources