.properties


.properties is a file extension for files mainly used in Java related technologies to store the configurable application. They can also be used for storing strings for Internationalization and localization; these are known as Property Resource Bundles.
Each parameter is stored as a pair of strings, one storing the name of the parameter, and the other storing the value.

Format

Each line in a.properties file normally stores a single property. Several formats are possible for each line, including key=value, key = value, key:value, and key value. Single-quotes or double-quotes are considered part of the string. Trailing space is significant and presumed to be trimmed as required by the consumer.
Comment lines in.properties files are denoted by the number sign or the exclamation mark as the first non blank character, in which all remaining text on that line is ignored. The backwards slash is used to escape a character. An example of a properties file is provided below.

  1. You are reading the ".properties" entry.
! The exclamation mark can also mark text as comments.
  1. The key characters =, and : should be written with
  2. a preceding backslash to ensure that they are properly loaded.
  3. However, there is no need to precede the value characters =, and : by a backslash.
website = https://en.wikipedia.org/
language = English
  1. The backslash below tells the application to continue reading
  2. the value onto the next line.
message = Welcome to \
Wikipedia!
  1. But if the number of backslashes at the end of the line is even, the next line is not included in the value. In the following example, the value for "key" is "valueOverOneLine\"
key = valueOverOneLine\\
  1. This line is not included in the value for "key"
  2. Add spaces to the key
key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
  1. The characters = and : in the key must be escaped as well:
key\:with\=colonAndEqualsSign = This is the value for the key "key:with=colonAndEqualsSign"
  1. Unicode
tab : \u0009
  1. If you want your property to include a backslash, it should be escaped by another backslash
path=c:\\wiki\\templates
  1. However, some editors will handle this automatically

In the example above, would be a key, and its corresponding value would be. While the number sign and the exclamation mark marks text as comments, it has no effect when it is part of a property. Thus, the key has the value and not. All of the whitespace in front of is excluded completely.
The encoding of a.properties file is ISO-8859-1, also known as Latin-1. All non-Latin-1 characters must be entered by using Unicode escape characters, e.g. \uHHHH where HHHH is a hexadecimal index of the character in the Unicode character set. This allows for using.properties files as resource bundles for localization. A non-Latin-1 text file can be converted to a correct.properties file by using the native2ascii tool that is shipped with the JDK or by using a tool, such as po2prop, that manages the transformation from a bilingual localization format into.properties escaping.
An alternative to using unicode escape characters for non-Latin-1 character in ISO 8859-1 character encoded Java *.properties files is to use the JDK's XML Properties file format which by default is UTF-8 encoded, introduced starting with Java 1.5.
Another alternative is to create custom control that provides custom encoding.
In Java 9 and newer, the default encoding for.properties files is UTF-8, and if an invalid UTF-8 byte sequence is encountered it falls back to ISO-8859-1.

Editing

Editing.properties files is done using any text editor such as those typically installed on various Operating Systems including Notepad on Windows or Emacs, Vim, etc. on Linux systems.
Third-party tools are also available with additional functionality specific to editing.properties files such as:
uses.properties files as well, but here they are UTF-8 encoded.
In Apache mod_jk's uriworkermap.properties format, an exclamation mark denotes a Negation operator when used as the first non blank character in a line.
Perl CPAN contains Config::Properties to interface to a.properties file.
SAP uses.properties files for localization within their framework SAPUI5 and its open-source variant OpenUI5