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

.properties files can use the number sign (#) or the exclamation mark (!) as the first non blank character in a line to denote that all text following it, is a comment. The backwards slash is used to escape a character. An example of a properties file is provided below.

# You are reading the ".properties" entry. ! The exclamation mark can also mark text as comments. website = http://en.wikipedia.org/ language = English # The backslash below tells the application to continue reading # the value onto the next line. message = Welcome to Wikipedia! # Add spaces to the key key with spaces = This is the value that could be looked up with the key "key with spaces". # Unicode tab : u0009

In the example above, website would be a key, and its corresponding value would be http://en.wikipedia.org/. 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 message has the value Welcome to Wikipedia! and not Welcome to Wikipedia. Note also that all of the whitespace in front of Wikipedia! is excluded completely.

In Apache Tomcat the exclamation mark denotes a Negation operator when used as the first non blank character in a line.

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 the use the JDK's XML Properties file format which by default is UTF-8 encoded, introduced starting with Java 1.5.

Adobe Flex uses .properties files as well, but here they are UTF-8 encoded.

Read more about this topic:  .properties

Other articles related to "formats, format":

Fansub - Legal and Ethical Issues
... uncut, unedited episodes of One Piece in multiple formats, releasing earlier season sections alongside boxsets more recent episodes in attempt to meet fan demand ... VIZ's boxset format releases for Naruto and Prince of Tennis also attempt to deliver larger chunks of a series to fans in a quick and efficient manner ... Yu-Gi-Oh in the mid 2000s, releasing a handful of volumes of each title in the format, but in an interview with ANN Alfred Kahn stated that "The market for them just isn't as large ...