properties file is a one of an data format for storing configuration and settings data in software projects.

This is mainly used in java and window applications to configure the settings which are going to change as per times or environment or user profiles.

properties file contains rows with line breaks, where each row of line contains key and values.

environment=production

Here key is name of variable which has a value production, and key and values are separated by equal(=) or colon(:) symbol sign.

The properties files are suitable for simple settings data and not suitable for complex structure of configuration. You can use yaml or toml file for nested settings configuration data.

These are similar to simple hashtable where each key and values are simple values.

valid properties file examples are

key=value
key1= value 1
key2:value2

Properties file extension Advantages

  • It is easy to read and write and format is human readable
  • Supports simple configuration with key and values
  • Mainly used in Java programming language and related frameworks but supports all popular programming language
  • Can write comments
  • properties contents are similar to Ini format in windows
  • Can maintain separate file for language strings during Internalization
  • Maintain single place for storing reusable configuration in java applications
  • Lines Starts with : and = are and blank lines ignored by processor

Disadvantages

  • No support for binary data
  • Complex values like table are not supported
  • Not suitable for complex nested configuration
  • Objects and tables data are not supported

properties file use cases

  • Properties files are used to maintain environment configuration data for development,testing ,staging and production
  • Configuration and settings of the software applications
  • Maintain separate properties for each local or language in I18N applications

Properties file extension

Extension is used to diffrentate the type of an file.

These files can be created with any IDE or Text Editor with file extension .properties

Rules

  • By Default, properties files extension is .properties
  • It supports UTF-8 encoding format only
  • Supports whitespaces, tabs and newlines asci code

Properties file MIME format type - text/plain

MIME stands for Multipurpose Internet Mail Extensions, and it is a request and response format that is sent between client and serve

Content-Type and accept headers in a request object are specified with this format Below is the mime type for this documents

text/x-java-properties

and request contains the below value for INI data sending over the internet

Content-type : text/x-java-properties

Default encoding

Default encoding for properties file ISO 8859-1character encoding.

All the read and writing object using java has a support this default encoding

How do you create and edit properties files.

Properties files can be created with plain editor or popular IDE

All the popular IDE supports the INI file extension and also provides plugins to validate the INI file content.

  • Notepad++
  • Eclipse
  • Visual Studio Code
  • Intelli IDEA