新增一个取文件名而不带后缀的整合方法,干净又卫生啊兄弟们
This commit is contained in:
		| @@ -17,6 +17,7 @@ import com.ruoyi.common.config.RuoYiConfig; | ||||
| import com.ruoyi.common.utils.DateUtils; | ||||
| import com.ruoyi.common.utils.StringUtils; | ||||
| import com.ruoyi.common.utils.uuid.IdUtils; | ||||
| import org.apache.commons.io.FilenameUtils; | ||||
|  | ||||
| /** | ||||
|  * 文件处理工具类 | ||||
| @@ -257,7 +258,7 @@ public class FileUtils | ||||
|  | ||||
|     /** | ||||
|      * 获取名称 | ||||
|      *  | ||||
|      *  例如: /profile/upload/2022/04/16/ruoyi.png, 返回: ruoyi.png | ||||
|      * @param fileName 路径名称 | ||||
|      * @return 没有文件路径的名称 | ||||
|      */ | ||||
| @@ -272,4 +273,19 @@ public class FileUtils | ||||
|         int index = Math.max(lastUnixPos, lastWindowsPos); | ||||
|         return fileName.substring(index + 1); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取名称 | ||||
|      * 例如: /profile/upload/2022/04/16/ruoyi.png, 返回: ruoyi | ||||
|      * @param fileName 路径名称 | ||||
|      * @return 没有文件路径的名称 | ||||
|      */ | ||||
|     public static String getNameNotSuffix(String fileName) { | ||||
|         if (fileName == null) { | ||||
|             return null; | ||||
|         } | ||||
|         String baseName = FilenameUtils.getBaseName(fileName); | ||||
|         return baseName; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user