• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading a .plist using Cocoa-Java [was: java - reading and writing preferences]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Re: Re: java - reading and writing preferences (Without Spelling Mistakes) (From: "J. Todd Slack" <email@hidden>)

  • Prev by Date: Re: Re: java - reading and writing preferences (Without Spelling Mistakes)
  • Next by Date: International Languages List?
  • Previous by thread: Re: Re: java - reading and writing preferences (Without Spelling Mistakes)
  • Next by thread: International Languages List?
  • Index(es):
    • Date
    • Thread