开发者

How can I read bytes from a file in iphone application, chunk by chunk?

开发者 https://www.devze.com 2022-12-13 02:40 出处:网络
I am trying to implement an iphone application which can read some fixed amount of bytes from a file and store in another file. this process will go on up to the开发者_如何学Python end of the file. I

I am trying to implement an iphone application which can read some fixed amount of bytes from a file and store in another file. this process will go on up to the开发者_如何学Python end of the file. I am very new to iphone application so please help me on that . Is there any parent classes out there for this specific type of implementation?


I had a very large file which couldn't be read with NSData methods, so I used the following (per TechZen's suggestion for fine grain control).

NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:filePath];
[fileHandle seekToFileOffset:offset];
NSData *data = [fileHandle readDataOfLength:length];


If you just want to copy the file, use NSFileManager's copy functions.

If you just want specific bytes in a file, you can load the file using NSData's file methods then you can get specific blocks of bytes and write them to file.

If you want more fine grain control, use NSFileHandler.

Edit01:

This page has examples for close to what you want. I don't have anything on hand.

0

精彩评论

暂无评论...
验证码 换一张
取 消