OpenersPrimaryExamplesSection(Spacer1)Examples  (6)

OpenersExampleSection0(Spacer1)Basic Examples  (6)

Export an association as a Java properties string:

ExportString[<|"tomcat.server.1" -> "host1", "tomcat.server.2" -> "host2"|>, "JavaProperties"]

Create a properties file:

file = CreateFile[];
WriteString[
file, 
"user = root
	password = 12345"
];

Import it as a Java properties file:

Import[file, "JavaProperties"]

Create properties file with comments:

file = CreateFile[];
WriteString[file, "
# admin user of the billing service database
db.user.billing.service = root
# we should consider choosing a stronger password
db.password.billing.service = 12345
"];

Import the data only, as an (RefLink[Association, paclet:ref/Association]):

Import[file, "JavaProperties"]

Import the data and the comments:

Import[file, {"JavaProperties", "AnnotatedData"}]

Spaces appearing in keys are escaped:

ExportString[<|"key with spaces" ->"values with spaces"|>, "JavaProperties"]

Values can span on more than one line:

ImportString["key = values \\
	spanned on \\
	multiple lines.", "JavaProperties"]

Special characters are formatted with the hexadecimal notation:

ExportString[<|"Wolf" ->"🐺"|>, "JavaProperties"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {Related Formats:  (RefLink[PHPIni, paclet:ref/format/PHPIni])  ▪  (RefLink[Ini, paclet:ref/format/Ini])  ▪  (RefLink[CSV, paclet:ref/format/CSV])  ▪  (RefLink[TSV, paclet:ref/format/TSV])  ▪  (RefLink[Text, paclet:ref/format/Text])  ▪  (RefLink[ApacheLog, paclet:ref/format/ApacheLog])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Importing & Exporting, paclet:guide/ImportingAndExporting])}, {▪(RefLinkPlain[Listing of All Formats, paclet:guide/ListingOfAllFormats])}, {▪(RefLinkPlain[Systems & Utility Formats, paclet:guide/SystemsAndUtilityFormats])}})}})