How to read OSX .plist files from Java?
Asked Answered
C

5

13

How to read OSX .plist files from Java?

Camelback answered 17/11, 2009 at 14:19 Comment(5)
HINT: A .plist is an XML file.Catechu
HINT @karim79: No. On Mac it can be in binary form tooWindflower
You should probably explain for readers what a .plist file is. It's a Mac file which is, as I understand, an XML-based format in its current incarnation. So, simply use Java's built in XML processing libraries to read it. But perhaps you should also say what you mean by 'read' -- simply get it into memory, parse it, what?Killick
Actually starting with Mac OS X 10.4 the default format for .plist files is in binary form not in xml formWindflower
dd-plist enables your Java application to handle property lists of various formats.Palmerpalmerston
R
15

Imho running a commandline tool from Java is not quite the "best way to do the job".

There are several much better ways to deal with binary plist in JAVA: That one I prefere is an usefull little project by Daniel Dreibrodt at: google project hosting

You can also use Apache Commons Configuration (which API is supporting the Property List format). More information about the history of the .plist-format on OSX (which version introduced which format) I wrote up on my blog

Update: There is a new project hosted at source forge called Property List Library, that shall be able to read AND write .plist- I have not tested it, but it sounds interesting.

Rubious answered 17/1, 2011 at 10:42 Comment(0)
W
4

I guess you refer to the plist format used on Mac starting with Mac OS X (and not the NeXTSTEP or GNUstep format).

  1. Determine if the file is in XML or binary format
  2. If in binary format use the plutil command-line-utility to convert file to xml format
  3. Now you have the file in xml format, use any java-xml-library to handle the plist
Windflower answered 17/11, 2009 at 14:25 Comment(1)
If you're looking for a utility that is available on platforms other than mac, you can look into scw.us/iPhone/plutil. Works fine for me on OS/X and linux, did not try windows.Unique
R
1

You can use this library:

Property List Library (SourceForge)

It will read property list files to objects and vice versa.

Rainwater answered 18/9, 2011 at 16:8 Comment(0)
B
0

Simplified java XML/plist reading.

Beguile answered 31/1, 2011 at 15:26 Comment(1)
xmlwise does NOT support binary plist format, which is actually the standard on OS X ("[Fatal Error] Info.plist:1:1: Content is not allowed in prolog")Rubious
P
0

These days the Java Preferences API on a Mac automatically uses plist files and they are in binary format. You might be able to read the plist automatically simply by reading the preferences at the "node".

I hope that helps.

Precinct answered 8/11, 2018 at 8:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.