Get file name without extension.
Ref:How to get file name without the extension?
Normally,there are two ways to implements this:use the library or the regular expression.
here I use the regular expression.
String s = "a.xml.ac.df.ef";
String result = s.replaceFirst("[.][^.]+$", "");
System.out.println(result);
//outputs:a.xml.ac.df
以上是不考虑到Path, 若有Path,需要先截断路径分隔符,如:
/**获取文件的简短名称,如将"G:\\video_record\\eclipse\\promt-workspace-startup.lxe"转为
* "promt-workspace-startup"
* @param fileFullName 文件的完整路径.
* @return
*/
public static String getFileNameWithoutExtention(String fileFullName) {
//截断路径分隔符.
int backslash = fileFullName.lastIndexOf("\\") != -1 ? fileFullName.lastIndexOf("\\") : fileFullName.lastIndexOf("/");
int dot = fileFullName.lastIndexOf(".");
if (backslash > 0 && dot > 0) {
fileFullName = fileFullName.substring(backslash + 1, dot);
}
return fileFullName;
}
Get file name without extension.的更多相关文章
- 小型文件数据库 (a file database for small apps) SharpFileDB
小型文件数据库 (a file database for small apps) SharpFileDB For english version of this article, please cli ...
- JavaIO之File类
Java-IO之File类 Java-IO之File类 1. File类 1.1. File类说明 1.2. 体验 File 类 1.3. 构造一个 File 类实例: 1.4. 路径: 1.4.1. ...
- Upload file
<h3>Upload File</h3> <form action="@Url.Action("Upload","UploadCo ...
- swift为UIView添加extension扩展frame
添加swift file:UIView+Extension import UIKit extension UIView { // x var x : CGFloat { get { return fr ...
- phpexcel导入excel文件报the filename xxx is not recognised as an OLE file错误。
工作中频繁会用phpexcel类导入excel文件的数据到数据库,目前常用的excel文件格式有:xls.csv.xlsx. 刚开始,针对xls文件,使用如下程序,能正常运行: $objReader ...
- How to upload a file in MVC4
Uploading a file in Asp.Net MVC application is very easy. The posted file is automatically available ...
- How to Create an PostgreSQL Extension
转自:https://severalnines.com/blog/creating-new-modules-using-postgresql-create-extension Extensibilit ...
- java File处理
/**************************************************************************************工具类********** ...
- error items-9022:missing required icon file.the bundle does not contain an app icon for iPhone/iPad Touch of exactly '120x120' pixels,in.pen format for ios versions >= 7.0
error items-9022:missing required icon file.the bundle does not contain an app icon for iPhone/iPad ...
随机推荐
- 介绍一个好用的软件--多个WIN远程连接
MultiDesk v3.162015-03-16 http://www.syvik.com/multidesk/index_chs.htm MultiDesk 是一个选项卡(TAB标签)方式的远程桌 ...
- UIKit的手风琴菜单,单条展开和多条同时展开
这个也要进来看看哈. 记得加多个属性时的用法就可以了. 因为官网提供太多的SAPMLE啦.. http://www.getuikit.net/docs/accordion.html <div c ...
- 14.6.8 Configuring the InnoDB Master Thread IO Rate 配置InnoDB 主线程IO 速率:
14.6.8 Configuring the InnoDB Master Thread IO Rate 配置InnoDB 主线程IO 速率: 主线程 在InnoDB 是一个线程 执行各种任务在后台. ...
- Android Studio启动时Fetching android sdk component information超时的解决方案
1)进入刚安装的Android Studio目录下的bin目录.找到idea.properties文件,用文本编辑器打开. 2)在idea.properties文件末尾添加一行: disable.an ...
- TCP/IP 目录导航
用了近二十天的时间,把一本800页的书看完,感觉收获还是很大的.对网络,对这些协议有了深刻的认识! 知道了路由器与交换机的区别. 知道了IP地址的特点. 知道了网络的分层,物理层,数据链路层,网络层, ...
- nginx -- 安装配置Nginx
安装说明 系统环境:CentOS-6.3 软件:nginx-1.2.6.tar.gz 安装方式:源码编译安装 安装位置:/usr/local/nginx 下载地址:http://nginx.org ...
- Unity Fresnel Hero(Dota2) Shader
Shader "HeroShader" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _Rim ...
- 走过而立之年的Coder
当年,关于“程序员三十”的话题,一直充斥在耳边——大抵就是:Coder过了三十就完犊子了.干不下去了.对于新人来讲,这个话题的热度,甚至超过了语言之争的月经贴. 那些话题总结一下,大抵就是如下几种: ...
- poj 2484 A Funny Game(博弈)
A Funny Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4639 Accepted: 2855 Desc ...
- [工具] slf4j-api、slf4j-log4j12以及log4j之间的关系
几乎在每个jar包里都可以看到log4j的身影,在多个子工程构成项目中,slf4j相关的冲突时不时就跳出来让你不爽,那么slf4j-api.slf4j-log4j12还有log4j是什么关系? ...