JavaProperties (.properties)

Background & Context

    • Configuration file format.
    • Commonly used in Java projects.
    • Associates string keys to string values.
    • Plain text format.
    • Uses ISO Latin-1 character encoding.

Import & Export

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Summary"summary of the file
    "Rules"list of rules for all available elements
  • Data representation elements:
  • "Data"data as an association
    "DataRules"data as a list of rules
    "CommentedData"data as a list of sections as rules, and comments as strings
  • The "JavaProperties" format exports elements of an association or a list.
  • "JavaProperties" treats an association as a list of properties. Keys and values are converted to strings using InputForm.
  • "JavaProperties" accepts lists containing a mixture of rules and strings. Rules are exported as properties; strings are exported as commented lines.
  • "JavaProperties" uses "ISOLatin1" (or "ISO8859-1") character encoding.
  • Unicode codepoints outside the ISO Latin-1 range are represented as "\uNNNN", where NNNN is the four-digit hexadecimal representation of the codepoint value.
  • A commented line starts with "!" or "#".
  • Values can span multiple lines. Each continuation line must end with a non-commented \.
  • The characters #, :, =, !, \, \t and \f are escaped with a preceding \.
  • Spaces are escaped when encountered in a key.
  • Newline characters are escaped when encountered in a value.


Basic Examples  (6)

Export an association as a Java properties string:

Create a properties file:

Import it as a Java properties file:

Create properties file with comments:

Import the data only, as an Association:

Import the data and the comments:

Spaces appearing in keys are escaped:

Values can span on more than one line:

Special characters are formatted with the hexadecimal notation: