Skip to main content

Tool to parse Java style properties file

Project description

Library to read Java style properties files. I don’t particularly like properties files but working with them in Java is very easy. I recently had to support reading Java properties files using Python.

This project is based on Benjamins Brent fork of pyjavaproperties.

The libraries main features are:

  • Reads properties files.

  • You can add new properties.

  • You can save properties to file.

  • It interprets variables in curly braces {} and dollar curly braces ${}.


The library does not interpret unicode characters correctly. If you include charactes like u4500 it will interpret it as , letter y and the number 4500.


Requires Python 3.3 or better.

$ pip install pyjavaprops


Loading Java properties

filename = os.path.join(TEST_DATA_FOLDER, '')
iso_8859_1_properties = JavaProperties()
with open(filename, encoding='iso-8859-1') as property_file:
     name = iso_8859_1_properties['name']

Saving Java properties to file

filename = os.path.join(TEST_DATA_FOLDER, '')
simple_java_properties = JavaProperties()
with open(filename) as property_file:
simple_java_properties['country'] = 'Angola'
output_filename = os.path.join(OUTPUT_FOLDER, '' %'%Y%m%d_%H%M'))
with open(output_filename, mode='w') as output:

Exporting to json

output_filename = os.path.join(OUTPUT_FOLDER, 'simple_%s.json' %'%Y%m%d_%H%M'))
export_to_json(output_filename, java_properties)
with open(output_filename) as json_data:
    json_properties = json.load(json_data)


Virtual Environment

To create the virtual environment

$ cd ~/virtual_environments

$ python3 /usr/local/lib/python3.4/site-packages/ --no-site-packages pyjavaprops_env

$ source ./pyjavaprops_env/bin/activate

(pyjavaprops_env) $

Runnig Tests

$ coverage run --source pyjavaprops test

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyjavaprops-1.0.2.tar.gz (7.2 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page