如何获得文件扩展名
来源:互联网 发布:华为工作 知乎 编辑:程序博客网 时间:2024/04/29 10:04
<script type="text/javascript"><!--google_ad_client = "pub-1654710028568330";/* 728x90, 创建于 08-5-19 */google_ad_slot = "5790075209";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script><script type="text/javascript"><!--google_ad_client = "pub-1654710028568330";/* 728x15, 创建于 08-5-19 */google_ad_slot = "1395130186";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
问题描述: 有一个String类型:String imageName = "zy.jpg"; 请问我如何截取"."后面的后辍名.
解法一:我的解法,使用正则表达式
package csdnTest;import java.util.regex.*;public class CSDNTest {public static void main(String[] ss){String s="abc.jpg";//String regex=".+?//.(.+)";这种写法也是可以的,但我认为没有后面的精确String regex=".+?//.([a-zA-z]+)";Pattern pt=Pattern.compile(regex);Matcher mt=pt.matcher(s);if(mt.find()){System.out.println(mt.group(1));}}}
解法二:
System.out.println(imageName.substring(imageName.lastIndexOf('.')+1));
或者
String FileType=imageName.substring(imageName.lastIndexOf('.')+1,imageName.length());
<script type="text/javascript"><!--google_ad_client = "pub-1654710028568330";/* 728x90, 创建于 08-5-19 */google_ad_slot = "5790075209";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script><script type="text/javascript"><!--google_ad_client = "pub-1654710028568330";/* 728x15, 创建于 08-5-19 */google_ad_slot = "1395130186";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 如何获得文件扩展名
- shell获得文件扩展名
- java获得文件扩展名
- 获得文件扩展名
- 获得文件名 文件的扩展名
- 怎样获得文件的扩展名
- 由文件路径获得扩展名
- 知道文件扩展名,如何获得在系统中该文件类型的图标
- struts2获取文件及获得扩展名
- C#如何获取文件扩展名
- 如何显示文件的扩展名
- XP如何显示文件扩展名
- js如何获取文件扩展名
- win7如何设置文件 扩展名
- 如何取得文件的扩展名
- win7如何显示文件扩展名?
- 如何获取文件的扩展名
- .dylib文件扩展名,.dylib文件如何打开?
- 名鸡~~
- 又梦见杀人了
- 木马的危害性
- Spring 之IOC
- 驱动开发学习(2)
- 如何获得文件扩展名
- 亚洲研究院微软笔试题
- myeclipse struts hibernate 整合异常
- C++虚拟函数实现
- 人民币汇率年内累计升值6.13%
- linux 防火墙(服务iptables和snortd)
- 中日就东海问题达成原则共识
- GNU Compile Tools, 可执行文件, 静态链接库, 动态链接库
- skinfeature界面产品特点介绍