# Import
Int main (int argc, const char * argv []) {@ autoreleasepool {// Method 1: NSFileManager instance method to read data NSArray * paths = NSSearchPathForDirectoriesInDomains (ns=topdirectory, NSUserDomainMask, YES); NSString * thepath = [paths lastObject]; thepath = [thepath stringByAppendingPathComponent: @ "fd_list.txt"]; NSLog (@ "desktop Directory: % @", thepath ); NSFileManager * fm = [NSFileManager defaultManager]; NSData * data = [[NSData alloc] init]; data = [fm contentsAtPath: thepath]; NSLog (@ "% @", [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]); // Method 2: NSData class method to read data = [NSData dataWithContentsOfFile: thepath]; NSLog (@ "the content read by the NSData method is: % @", [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]); // method 3: NSString class read content NSString * content = [NSString stringWithContentsOfFile: thepath encoding: NSUTF8StringEncoding error: nil]; NSLog (@ "NSString class read content: \ n % @", content); // Method 4: NSFileHandle instance method reads content NSFileHandle * fh = [NSFileHandle fileHandleForReadingAtPath: thepath]; data = [fh readDataToEndOfFile]; NSLog (@ "the content read by the NSFileHandle instance is \ n % @", [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]);} return 0 ;}