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.的更多相关文章

  1. 小型文件数据库 (a file database for small apps) SharpFileDB

    小型文件数据库 (a file database for small apps) SharpFileDB For english version of this article, please cli ...

  2. JavaIO之File类

    Java-IO之File类 Java-IO之File类 1. File类 1.1. File类说明 1.2. 体验 File 类 1.3. 构造一个 File 类实例: 1.4. 路径: 1.4.1. ...

  3. Upload file

    <h3>Upload File</h3> <form action="@Url.Action("Upload","UploadCo ...

  4. swift为UIView添加extension扩展frame

    添加swift file:UIView+Extension import UIKit extension UIView { // x var x : CGFloat { get { return fr ...

  5. phpexcel导入excel文件报the filename xxx is not recognised as an OLE file错误。

    工作中频繁会用phpexcel类导入excel文件的数据到数据库,目前常用的excel文件格式有:xls.csv.xlsx. 刚开始,针对xls文件,使用如下程序,能正常运行: $objReader ...

  6. How to upload a file in MVC4

    Uploading a file in Asp.Net MVC application is very easy. The posted file is automatically available ...

  7. How to Create an PostgreSQL Extension

    转自:https://severalnines.com/blog/creating-new-modules-using-postgresql-create-extension Extensibilit ...

  8. java File处理

    /**************************************************************************************工具类********** ...

  9. 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. Occupy Cities

    hdu4606:http://acm.hdu.edu.cn/showproblem.php?pid=4606 题意:在一个二维坐标系中,有n个城市,坐标给出来了,然后有p个士兵要去占领这n个城市,但是 ...

  2. 使用lombok

    Lombok是一种JavaArchive(JAR)文件,可用来消除Java代码的冗长.通过在开发环境中实现Lombok,开发人 员可以节省构建诸如hashCode()和equals()这样的方法以及以 ...

  3. Qt4.8 移植(超详细Configure的参数)

    Qt4.8.6 configure 参数 不只是适用于Qt4.8.6,原则上适用于Qt4所有版本 Usage: configure [-h] [-prefix <dir>] [-prefi ...

  4. 【HDOJ】3584 Cube

    三位树状数组. /* 3584 */ #include <iostream> #include <string> #include <map> #include & ...

  5. vijosP1779国王游戏

    题目:https://vijos.org/p/1779 题解:忽然想起来我好像还没写过高精度除以单精度,于是拿这题练练手...没想到1A了... 代码: #include<cstdio> ...

  6. web.xml中的contextConfigLocation的作用

    在web.xml中通过contextConfigLocation配置spring,contextConfigLocation 参数定义了要装入的 Spring 配置文件. 如果想装入多个配置文件,可以 ...

  7. HDU 3507 Print Article(DP+斜率优化)

     Print Article Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) ...

  8. iOS设备保持横排方向

    //保持横排方向 -(NSUInteger)supportedInterfaceOrientations{     returnUIInterfaceOrientationMaskLandscapeL ...

  9. 【原】centos6.5下cdh4.6 Oozie安装

    0.oozie只需安装在一台服务器上,这里选择在namenode上来安装:安装用户为cloud-user 1.安装Oozie包:    sudo yum install -y oozie oozie- ...

  10. 《Numerical Methods》-chaper7-解线性方程组的直接方法和最小二乘问题

    基于我们在线性代数中学习过的知识,我们知道解线性方程组本质上就是Gauss消元,也就是基于增广矩阵A的矩阵初等变换.关于数学层面的内容这里不做过多的介绍,这里的侧重点是从数值计算的角度来看这些常见的问 ...