Is there any Ja开发者_运维百科va library that can read and write plist files, including in their binary format?
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.
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.
精彩评论