【问题标题】:Is there any Java library that can read and write plist files, including binary format?有没有可以读写plist文件的Java库,包括二进制格式?
【发布时间】:2011-06-20 09:26:25
【问题描述】:

是否有任何 Java 库可以读写 plist 文件,包括它们的二进制格式?

【问题讨论】:

    标签: java xml plist


    【解决方案1】:

    dd-plist可以读写Cocoa框架二进制.plist文件。

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

    它还可以将 plist 转换为 XML 并返回。例如:

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

    PropertyListParser.parse 然后可以读回.plist 以及.xml 格式。


    注意:还有Apache Commons Configuration,但它只能读/写旧式(ASCII)plist文件,现在iOS或macOS上从未使用过。

    【讨论】:

      【解决方案2】:

      您是否尝试过使用 Apache Commons Configuration ?它们似乎提供了使用 PropertyListConfigurationorg.apache.commons.configuration.plist 包的其他类的您正在寻找的东西。

      【讨论】:

      • 处理文本和 XML 格式,但不处理二进制格式。 OP 也想要二进制格式,但这无疑是一个很好的开始。
      猜你喜欢
      • 1970-01-01
      • 2017-09-21
      • 1970-01-01
      • 1970-01-01
      • 2011-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-12
      相关资源
      最近更新 更多