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