Skip to content
Read a java properties file in python
Python Shell Java
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


Linux build status

Read the key, element pairs from a java properties file

Follows the java properties file format and tested against the Java 8 version of java.util.Properties


dict getJavaProperties(file)

  • Args:
    • file: a valid file object (as returned by open(filename))
  • Returns:
    • The property key and elements as a dict
  • Raises:
    • IOError: if file operation fails with I/O related reason
      • Corresponds to java IOException in Properties.load()
    • UnicodeDecodeError: if the property file has malformed \uxxxx encoding,
      • Corresponds to java IllegalArgumentException in Properties.load()
    • AttributeError: if invalid object was provided for file object
      • Corresponds to java NullPointerException


import jprops

props = jprops.getJavaProperties(open(""))
print props['greeting']
$ cat
greeting = hello world
$ python
hello world
You can’t perform that action at this time.