//NSFileHandle 主要負責對文件內容進行讀取和寫入操作 注意此對象不能創建文件
NSString *home = [NSHomeDirectory() stringByAppendingString:@"/Documents/10.txt"];
/*
//讀取寫入數據
NSFileHandle *handle = [NSFileHandle fileHandleForWritingAtPath:home];
//設置到文件末尾 類似於追加數據
[handle seekToEndOfFile];
//寫入數據
[handle writeData:[@"sucessfuly!" dataUsingEncoding:NSUTF8StringEncoding]];
*/
NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:home];
//從當前的偏移量移動到文件結尾
[handle seekToEndOfFile];
//設置指定偏移量
[handle seekToFileOffset:1];
//獲取當前偏移量
[handle offsetInFile];
//從當前偏移量讀取到結尾
[handle readDataToEndOfFile];
//從指定偏移量開始讀取指定長度數據
[handle readDataOfLength:100];
//讀取數據
NSLog(@"%@",[[NSString alloc] initWithData:[handle availableData] encoding:NSUTF8StringEncoding]);
//關閉文件流
[handle closeFile];