deason 3 年之前
父节点
当前提交
c94a8e4820
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. 15 0
      examcloud-commons/src/main/java/cn/com/qmth/examcloud/commons/util/FileUtil.java

+ 15 - 0
examcloud-commons/src/main/java/cn/com/qmth/examcloud/commons/util/FileUtil.java

@@ -44,6 +44,21 @@ public class FileUtil {
         });
     }
 
+    /**
+     * 获取文件名(包含后缀名)
+     */
+    public static String getFileName(String filePath) {
+        if (filePath == null) {
+            return "";
+        }
+        filePath = filePath.replace("\\", "/");
+        int index = filePath.lastIndexOf("/");
+        if (index > -1) {
+            return filePath.substring(index + 1);
+        }
+        return filePath;
+    }
+
     /**
      * 获取文件后缀名,包括"."
      */