mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:20:07 +08:00
FileTypeUtil.getType增加文件判断
This commit is contained in:
parent
144daf3e51
commit
7a4f295be0
@ -2,7 +2,7 @@
|
||||
# 🚀Changelog
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.19.M1 (2023-05-15)
|
||||
# 5.8.19.M1 (2023-05-19)
|
||||
|
||||
### 🐣新特性
|
||||
* 【db 】 优化HttpRequest.toString()内容打印(issue#3072@Github)
|
||||
@ -12,6 +12,7 @@
|
||||
* 【core 】 邮箱校验添加对中文的支持(pr#997@Gitee)
|
||||
* 【core 】 FileUtil.getMimeType增加webp识别(pr#997@Gitee)
|
||||
* 【core 】 SyncFinisher增加setExceptionHandler方法(issue#I716SX@Gitee)
|
||||
* 【core 】 FileTypeUtil.getType增加文件判断(pr#3112@Github)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【core 】 修复URLUtil.decode无法解码UTF-16问题(issue#3063@Github)
|
||||
|
@ -1,11 +1,12 @@
|
||||
package cn.hutool.core.io;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
@ -195,6 +196,9 @@ public class FileTypeUtil {
|
||||
* @throws IORuntimeException 读取文件引起的异常
|
||||
*/
|
||||
public static String getType(File file,boolean isExact) throws IORuntimeException {
|
||||
if(false == FileUtil.isFile(file)){
|
||||
throw new IllegalArgumentException("Not a regular file!");
|
||||
}
|
||||
FileInputStream in = null;
|
||||
try {
|
||||
in = IoUtil.toStream(file);
|
||||
|
Loading…
Reference in New Issue
Block a user