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["file.properties"] returns a representation of a properties file as an Association.
- Import["file","JavaProperties"] returns a representation of a file as a properties file.
- Import["file.properties",elem] returns the specified data representation of a properties file.
- See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
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 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.
Examples
Basic Examples (6)
Export an association as a Java properties string:
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: