?//讀取文件 文件來源 1.本地文件 2.網(wǎng)絡(luò)文件
? ? ? ? NSURL*httpUrl = [NSURLURLWithString:str10];//網(wǎng)絡(luò)路徑
? ? ? ? NSURL*fileUrl = [NSURLfileURLWithPath:str10];//本地路徑
-----------------------------------------------------------------------------------------------------------------
? ? ? ? //讀取網(wǎng)絡(luò)文件
? ? ? ? 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(@"文件寫入失敗");
? ? ? ? }
-----------------------------------------------------------------------------------------------------------------