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. 【 POJ - 3801】Crazy Circuits(有源汇、上下界最小流)

    Description You’ve just built a circuit board for your new robot, and now you need to power it. Your ...

  2. ArtisticStyle----很好用的C/C++样式格式化工具

    下载地址:http://srgb.googlecode.com/files/AStyle_2.02_windows.7z 把astyle.exe 复制到 C:\WINDOWS 目录里,省的指定路径VC ...

  3. Android开发详解之onTouch和onClick详解

    android组件中的onTouch,onClick,onLongClick事件发生先后顺序和关联: 一,onTouch返回false 首先是onTouch事件的down事件发生,此时,如果长按,触发 ...

  4. Node.js权威指南 (4) - 模块与npm包管理工具

    4.1 核心模块与文件模块 / 574.2 从模块外部访问模块内的成员 / 58 4.2.1 使用exports对象 / 58 4.2.2 将模块定义为类 / 58 4.2.3 为模块类定义类变量或类 ...

  5. 【转】Android--多线程之Handler--不错

    原文网址:http://www.cnblogs.com/plokmju/p/android_handler.html 前言 Android的消息传递机制是另外一种形式的“事件处理”,这种机制主要是为了 ...

  6. vs默认的app.config是哪个?

    一:这次是进一步的三层构架,不过还是没有业务逻辑层,但有单独的层的文件夹,解决方案资源管理器图如下: 二:operatorDAl.cs代码: using System; using System.Co ...

  7. 使用doxygen生成注释文档

    1. doxygen下载地址:http://www.stack.nl/~dimitri/doxygen/ 2. 参考http://wenku.baidu.com/link?url=ETvBUyaR9f ...

  8. HDOJ 2011 多项式求和

    Problem Description 多项式的描述如下: 1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + - 现在请你求出该多项式的前n项的和. Input 输入数据由2行组成, ...

  9. java多线程编程(2)交替输出数字和字母

    mark一下,不停的看看notify和wait的没有理解 class Printer { int index=0; //输出奇数 public synchronized void printA(int ...

  10. 《A First Course in Probability》-chaper2-概率论公理

    概率论自身有一套很深的理论体系,读过<几何原本>的读者会知道,伟大的欧几里得之所以伟大,是因为它基于几条最基本的公理,推导除了整个欧式几何学的理论体系,同样,在概率论这里,一切的推导都是源 ...