//读取文件 文件来源 1.本地文件 2.网络文件
NSURL*httpUrl = [NSURLURLWithString:str10];//网络路径
NSURL*fileUrl = [NSURLfileURLWithPath:str10];//本地路径
-----------------------------------------------------------------------------------------------------------------
//读取网络文件
NSString *httpStr = [NSString stringWithContentsOfURL:httpUrl encoding:NSUTF8StringEncoding error:nil];
NSLog(@"httpStr =%@",httpStr);
-----------------------------------------------------------------------------------------------------------------
//读取本地文件
NSString *fileStr = [NSString stringWithContentsOfFile:@"/Users/macmini/Desktop/log.txt" encoding:NSUTF8StringEncoding error:nil];
NSLog(@"fileStr =%@",fileStr);
-----------------------------------------------------------------------------------------------------------------
//写入文件
BOOL isOK = [str10 writeToFile:@"/Users/macmini/Desktop/Demo.txt" atomically:YES encoding:NSUTF8StringEncoding error:nil];
if(isOK) {
NSLog(@"文件写入成功");
}else{
NSLog(@"文件写入失败");
}
-----------------------------------------------------------------------------------------------------------------