0

我想从Objective-Ci中的文本文件中读取分隔符后的字符串,我仍然在努力获取它:(....这是我已经完成直到nw,但是当我在第7行打印数据缓冲区的内容时下面的代码,读取的数据是封装在一个NSData对象中返回的,如何转换成Readable格式呢?

NSData *databuffer;

file = [NSFileHandle fileHandleForReadingAtPath: @"/tmp/myfile.txt"];

if (file == nil)
        NSLog(@"Failed to open file");

[file seekToFileOffset: 10];

databuffer = [file readDataOfLength: 6];

NSLog(@"Contents of buffer = %s", databuffer);

[file closeFile];
4

1 回答 1

0
NSString* aStr = [[NSString alloc] initWithData:databuffer encoding:NSASCIIStringEncoding];
于 2010-02-04T12:17:32.067 回答