Re: Reading a .plist using Cocoa-Java [was: java - reading and writing preferences]
Re: Reading a .plist using Cocoa-Java [was: java - reading and writing preferences]
- Subject: Re: Reading a .plist using Cocoa-Java [was: java - reading and writing preferences]
- From: Dave Thorup <email@hidden>
- Date: Thu, 22 Apr 2004 10:44:03 -0400
On Apr 22, 2004, at 10:04 AM, J. Todd Slack wrote:
I have a plist file that i need to read from. Its generated as the
output of
"system_profiler -xml -detailLevel -1 > output.plist"
Since Objective-C is foreign to you, stay Java.
To start you off, why don't you look at XML Parsing in Java, Create a
DOM
tree and traverse it to get your information.
You can do this much easier using the Cocoa-Java APIs (see below).
On Apr 22, 2004, at 9:49 AM, Nick Zitzmann wrote:
I'm not sure about Java, but in Objective-C, you'd do this:
NSArray *data = [NSArray
arrayWithContentsOfFile:@"/Path/To/output.plist"];
In Cocoa-Java it isn't quite as obvious as in Objective-C (Warning,
typed in Mail):
NSArray data;
data = (NSArray)NSPropertyListSerialization.propertyListFromXMLData(new
NSData(new File("/path/to/file.plist")));
Now you can use "data" just like any other NSArray. It's left to you
to figure out what information you want to get from the System
Profiler's output.
_____________________________
Dave Thorup
Software Engineer
email@hidden
http://www.kuwan.net
Defaults Manager - The premier editor for Mac OS X's User Defaults /
Preferences database.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.