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 ...
随机推荐
- 第1章 开发环境安装和配置(二)安装JDK、SDK、NDK
原文 第1章 开发环境安装和配置(二)安装JDK.SDK.NDK 无论是用C#和VS2015开发Androd App还是用Java和Eclipse开发Androd App,都需要先安装JDK和Andr ...
- MySQL安装完可以使用,但是找不到对应的系统服务
为何我用 mysqld 启动 mysql 的服务后,在系统“服务”中查不到mysql服务呢?首先声明,我的服务启动成功了,因为我可以另开一个 cmd 窗口进行mysql登录,登录后可以进行各种操作.用 ...
- 【HDOJ】3397 Sequence operation
线段树的应用,很不错的一道题目.结点属性包括:(1)n1:1的个数:(2)c1:连续1的最大个数:(3)c0:连续0的最大个数:(4)lc1/lc0:从区间左边开始,连续1/0的最大个数:(5)rc1 ...
- luoguP2266 爱的距离
题目:http://www.luogu.org/problem/show?pid=2266 题解:感觉题意不清,就去瞅题解了T_T 然后发现好水... 类似于MST,我们把边从小到大加进去就可以了. ...
- touchend事件的preventDefault阻止掉了click事件
<div id="box">box</div> <script> var isTouchDevice = function() { return ...
- jQuery 属性操作和CSS 操作
如有在jQuery方法中涉及到函数,此函数必定会返回一个数值(函数由于运行次数不同触发一些不同效果) jQuery 属性操作方法(以下方法前些日子学习过,不再赘述) addClass() attr() ...
- html/php, 二个文本框求和,在第三个框中显示
我想要实现的是第三个文本框本来输出的是默认值,按了提交按钮之后,显示了一个我通过php某个计算后想要输出的值,如何实现?就好比说:我输入两个数,我按了个提交按钮之后,那个第三个文本框本来输出是“输出框 ...
- 国内maven镜像
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> & ...
- android进程间通信:使用AIDL
android 的binder其实是基于 openbinder实现的,openbinder的地址:http://www.angryredplanet.com/~hackbod/openbinder/d ...
- C# Timer执行方法
private void button3_Click(object sender, EventArgs e) { System.Timers.Timer t = new System.Timers.T ...