deason 3 年 前
コミット
c94a8e4820

+ 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;
+    }
+
     /**
      * 获取文件后缀名,包括"."
      */