iOS 从url中获取文件名以及后缀
//这里有一个模拟器沙盒路径(完整路径)
NSString* index=@"/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip";
对路径截取的9种操作
NSLog(@"1=%@",[index lastPathComponent]);
NSLog(@"2=%@",[index stringByDeletingLastPathComponent]);
NSLog(@"3=%@",[index pathExtension]);
NSLog(@"4=%@",[index stringByDeletingPathExtension]);
NSLog(@"5=%@",[index stringByAbbreviatingWithTildeInPath]);
NSLog(@"6=%@",[index stringByExpandingTildeInPath]);
NSLog(@"7=%@",[index stringByStandardizingPath]);
NSLog(@"8=%@",[index stringByResolvingSymlinksInPath]);
NSLog(@"9=%@",[[index lastPathComponent] stringByDeletingPathExtension]);
对应结果
1=2013_50.zip
2=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books
3=zip
4=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50
5=~/Documents/DownLoad/books/2013_50.zip
6=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip
7=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip
8=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip
9=2013_50
iOS 从url中获取文件名以及后缀的更多相关文章
- Qt url中获取文件名
QString filename = reply->rawHeader("Content-Disposition"); filename = filename.mid(QSt ...
- angularjs 文件下载 并 从response header中获取文件名
最近在做一个下载文件的功能,后台接口给的是二进制流的方式,那么前端要把二进制流下载下来. 这个过程使用$http的get请求,使用Blob接收,倒是没有难度,主要是遇到了,后台的文件名拿不到 的问题. ...
- Python开发【笔记】:从海量文件的目录中获取文件名--方法性能对比
Python获取文件名的方法性能对比 前言:平常在python中从文件夹中获取文件名的简单方法 os.system('ll /data/') 但是当文件夹中含有巨量文件时,这种方式完全是行不通 ...
- js使用正则表达式从url中获取参数值
//从url中获取参数值 function getvl(name) { var reg = new RegExp("(^|\\?|&)"+ name +"=([^ ...
- FileUtils【获取SD卡根目录、读写文件、移动、复制、删除文件、获取文件名、后缀名操作类】
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 封装了获取SD卡根目录路径.以及对文件读写.获取文件名等相关操作. 因为需要用到android.permission.READ_EX ...
- php获取文件名和后缀名
php获取文件名 1 function retrieve($url) 2 { 3 preg_match('/\/([^\/]+\.[a-z]+)[^\/]*$/',$url,$match); 4 re ...
- python和C语言从路径中获取文件名
1.Python import os file_name = os.path.basename(filepath)#带后缀的文件名(不含路径) file_name_NoExtension = os.p ...
- IOS从视频中获取截图
从视频中获取截图: NSString *movpath =[[NSBundle mainBundle] pathForResource:@”iosxcode4″ ofType:@”mov”]; mpv ...
- iOS 通过URL网络获取XML数据的两种方式
转载于:http://blog.csdn.net/crayondeng/article/details/8738768 下面简单介绍如何通过url获取xml的两种方式. 第一种方式相对简单,使用NSD ...
随机推荐
- C++拷贝构造&操作符重载
头文件 DString.h如下 #ifndef __DSTRING_H #define __DSTRING_H #endif #include <stddef.h> class DStri ...
- Extjs中创建Tree菜单【一】
此篇treepanel的描写是很简单,没有太大的难度,在学习时,可以先熟悉tree的一些配置信息.属性.方法和事件. 然后先写一个简单的例子,慢慢了解从中如何实现的,然后在慢慢的深入了解,实现一些复杂 ...
- maven构建maven-project和maven-module
在Eclipse中创建Maven多模块工程的例子 更多0 如果,你需要创建多个项目,项目之间即独立又有关系,那么创建一个Maven多模块项目是个非常好的选择,也非常cool!怎么在Eclipse里 ...
- 黑苹果macOS Sierra 10.12 安装教程(venue11 pro测试)
黑苹果macOS Sierra 10.12 安装教程(venue11 pro测试) 2017-03-12 03:46:24 by SemiconductorKING PS:刚刚装好黑苹果,来记录一篇折 ...
- Struts2中的配置文件的加载
Struts2框架配置文件加载顺序(服务器启动之后, 这些配置文件会按照顺序一一加载进内存, 进行类等匹配的时候才会去内存查找): 1. default.properties 2. str ...
- [Spark] - SparkCore程序优化总结
http://spark.apache.org/docs/1.6.1/tuning.html1) 代码优化 a. 对于多次使用的RDD,进行数据持久化操作(eg: cache.persist) b. ...
- springmvc基础学习3---注解简单理解
1:@Controller 用来注解这个bean是MVC模型中的一个C 会被spring的auto-scan扫到纳入管理.Spring mvc框架中的action层注入,也就是控制层.控制器Contr ...
- FastCGI超过活动超时时间
线上环境:PHP5.4 and IIS 打开IIS管理器,找到FastCGI,打开后编辑选项 活动超时默认为70(秒) 请求超时默认为90(秒) 可根据项目需求来更改这两项的值
- golang socket 分析
socket:tcp/udp.ip构成了网络通信的基石,tcp/ip是面向连接的通信协议 要求建立连接时进行3次握手确保连接已被建立,关闭连接时需要4次通信来保证客户端和,服务端都已经关闭 在通信过程 ...
- nfs mount:reason given by server: Permission denied
遇到nfs mount的问题,以前从未遇到过,问题出的很奇怪,现象是 mount: 10.1.10.22:/cicro failed, reason given by server: Permissi ...