How can I read an mbox file (or any simple data) in Cocoa?
How can I read an mbox file (or any simple data) in Cocoa?
- Subject: How can I read an mbox file (or any simple data) in Cocoa?
- From: Denis Stanton <email@hidden>
- Date: Sat, 15 Mar 2003 18:46:49 +1300
I'm trying to read the text from a Mail mbox file, but I cannot
determine the proper class to use to get that data. I know this is
pretty basic, but I have been through many documentation sources and I
haven't found the answer yet.
I already have a WebObjects/Java program that does what I want. Now I
need to do the same thing in Cocoa. In my Java app I defined a
FileInputStream and a BufferedReader and then called .readLine on it.
I would dearly like to find something similar in the Cocoa API. So far
everything I get tells me that old-fashioned data files are deprecated
and I should be archiving dictionaries or plists. The documentation
and tutorials I have found all assume that I am creating the file so I
can use a superior format. They don't seem to offer anything for
reading existing files that are not in this format.
In Java I would write something like:
String filename =
"/Users/myname/Library/Mail/POP-myaccount/INBOX.mbox/mbox";
try {
FileInputStream inputStream = new FileInputStream(filename);
BufferedReader myReader = new BufferedReader(new
InputStreamReader(inputStream));
String myString = myReader.readLine();
........
can anybody suggest what I should be looking at to do this in Cocoa?
I have got as far as;
NSString *thePath =
@"/Users/myname/Library/Mail/POP-myaccount/INBOX.mbox/mbox";
NSData *myData = [NSData dataWithContentsOfFile:thePath];
but everything I do with myData, such as [myData getBytes:aBuffer];
gives a sigbus error.
Denis Stanton
email@hidden
Home: +64 9 533 0391
mobile: +64 21 1433622
_______________________________________________
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.