sorin
sorin

Reputation: 170688

Is there any Java library that can read and write plist files, including binary format?

Is there any Java library that can read and write plist files, including in their binary format?

Upvotes: 3

Views: 785

Answers (2)

rustyx
rustyx

Reputation: 85481

dd-plist can read and write Cocoa framework binary .plist files.

NSDictionary rootDict = (NSDictionary) PropertyListParser.parse(new File("my.plist"));
for (String name : rootDict.allKeys()) {
    NSObject value = rootDict.objectForKey(name);
    System.out.println(name + " = " + value);
}

It can also convert a plist to XML and back. e.g.:

PropertyListParser.convertToXml(new File("my.plist"), new File("my.xml"));

PropertyListParser.parse can then read back .plist as well as .xml format.


Note: there's also Apache Commons Configuration, but it can only read/write old-style (ASCII) plist files, which are never used on iOS or macOS nowadays.

Upvotes: 1

Riduidel
Riduidel

Reputation: 22300

Have you tried using Apache Commons Configuration ? They seem to provide what you're looking for using PropertyListConfiguration and other classes of the org.apache.commons.configuration.plist package.

Upvotes: 0

Related Questions