zoukankan      html  css  js  c++  java
  • Java获取路径中的文件名(正则表达式)

    Java获取路径中的文件名(正则表达式)

    目标

    在这个路径中我想得到model2

    /E:/2017-02-21--SoftWare/github/test/Java/poiDemo_word2excel/target/test-classes/model2.docx

    操作

    String srcFile="/E:/2017-02-21--SoftWare/github/test/Java/poiDemo_word2excel/target/test-classes/model2.docx";

    String temp[]=srcFile.split("\/");

    此时temp数组为:

    E:
    2017-02-21--SoftWare
    github
    test
    Java
    poiDemo_word2excel
    target
    test-classes
    model2.docx

    然后我们

    String temp1=temp[temp.length-1];

    此时temp1=“model2.docx”

    然后我们在按照.点号spilt

    String temp3[]=temp1.split("\.");

    String txtFileName=temp3[0];

    那么现在txtFileName就为model2

  • 相关阅读:
    Web开发快速上手
    前端概述
    Python语言进阶
    图像和办公文档处理
    网络编程
    进程和线程
    正则表达式
    面向对象进阶
    面向对象
    js 获取指定时间上月26 ,
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/8157546.html
Copyright © 2011-2022 走看看