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. JPA2.1 中三个提升应用性能的新功能

    经常在网上看到开发者们抱怨 JPA 性能低下的帖子或文章,但如果仔细查看这些性能问题,常会发现导致问题的根本原因大致包括以下几个: 使用过多的 SQL 查询从数据库中获取所需的实体信息,即我们常说的n ...

  2. 转:synchronized和LOCK的实现原理---深入JVM锁机制

    JVM底层又是如何实现synchronized的? 目前在Java中存在两种锁机制:synchronized和Lock,Lock接口及其实现类是JDK5增加的内容,其作者是大名鼎鼎的并发专家Doug ...

  3. asp.net 类库中获取session c#类中获取session

    asp.net  类库中获取session c#类中获取session 1. 先引入命名空间 using System.Web; using System.Web.SessionState; 在使用H ...

  4. Linux Kernel 多个本地拒绝服务漏洞

    漏洞名称: Linux Kernel 多个本地拒绝服务漏洞 CNNVD编号: CNNVD-201308-154 发布时间: 2013-08-12 更新时间: 2013-08-12 危害等级:    漏 ...

  5. 【转】使用命令行方式创建和启动android模拟器

    原文网址:http://blog.csdn.net/tiandinilv/article/details/8953001 1.Android模拟器介绍 Android中提供了一个模拟器来模拟ARM核的 ...

  6. 游戏开发设计模式之原型模式 & unity3d JSON的使用(unity3d 示例实现)

    命令模式:游戏开发设计模式之命令模式(unity3d 示例实现) 对象池模式:游戏开发设计模式之对象池模式(unity3d 示例实现) 实现原型模式 原型模式带来的好处就是,想要构建生成任意独特对象的 ...

  7. 1‘b0 什么意思

    在看datasheet 中有类似表达式如下: 3'b000, 1'b1, 1'b0; 3'b000这个表示:b代表二進制.3代表位元數. 1'b1:宣告為一位元二進制之值為1,一般除了可以宣告b外,也 ...

  8. iframe 中嵌套刷新

    if(top.frames.length>0){top.location.href = window.location.href;}

  9. 细谈Java

    重载:相同函数名,不同参数. 重写(覆写):父类和子类之间的,子类重写了父类的方法. java的多态:重载+覆写 1.      Main方法: 是public的,也是static,也是void的,参 ...

  10. firefox如何restart重启

    1.开发者工具栏可以对firefox进行重启,不是关闭firefox又打开那种重启