// 读取文件内容 // 方法1:按照文件路径读取 NSString *pathBundle = [[NSBundle mainBundle]pathForResource:@"aa" ofType:@"txt"]; NSString *outstringbundle = [NSString stringWithContentsOfFile:pathBundle encoding:NSUTF8StringEncoding error:nil]; // 方法2:按照URL读取 NSURL *pathUrl = [[NSBundle mainBundle]URLForResource:@"aa" withExtension:@"txt" subdirectory:nil]; NSString *outstringUrl = [NSString stringWithContentsOfURL:pathUrl encoding:NSUTF8StringEncoding error:nil]; NSLog(@"%@\n////////\n%@",outstringbundle,outstringUrl);
2016-03-30 14:48:02.939 沙盒机制and文件路径[11786:518929] 百度: www.baidu.com //////// 百度: www.baidu.com
NSString *newPath = [NSString stringWithFormat:@"%@/Documents/New",NSHomeDirectory()]; // 先把文件路径和文件名定义好 NSString *newfile = [NSString stringWithFormat:@"%@/new.mp3",newPath]; // 使用createFileAtPath创建文件 [[NSFileManager defaultManager]createFileAtPath:newfile contents:nil attributes:nil]; NSLog(@"%@",newPath);
// 写入文件 // 1、先用data读取数据 NSData *data = [[NSData alloc]initWithContentsOfFile:pathBundle]; NSLog(@"%@",data); // 2、把读取的data写入沙盒文件,newfile为上面在沙盒文件中创建的mp3文件 [data writeToFile:newfile atomically:YES];
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有