public final class FileTypeUtil extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
getType(File file)
根据文件流的头部信息获得文件类型
|
static String |
getType(InputStream in)
根据文件流的头部信息获得文件类型
|
static String |
getType(String fileStreamHexHead)
根据文件流的头部信息获得文件类型
|
static String |
getTypeByPath(String path)
通过路径获得文件类型
|
static String |
putFileType(String fileStreamHexHead,
String extName)
增加文件类型映射
如果已经存在将覆盖之前的映射 |
static String |
removeFileType(String fileStreamHexHead)
移除文件类型映射
|
public static String putFileType(String fileStreamHexHead, String extName)
fileStreamHexHead - 文件流头部Hex信息extName - 文件扩展名public static String removeFileType(String fileStreamHexHead)
fileStreamHexHead - 文件流头部Hex信息public static String getType(String fileStreamHexHead)
fileStreamHexHead - 文件流头部16进制字符串nullpublic static String getType(InputStream in) throws IORuntimeException
in - InputStreamnullIORuntimeException - 读取流引起的异常public static String getType(File file) throws IORuntimeException
file - 文件 FilenullIORuntimeException - 读取文件引起的异常public static String getTypeByPath(String path) throws IORuntimeException
path - 路径,绝对路径或相对ClassPath的路径IORuntimeException - 读取文件引起的异常Copyright © 2018. All rights reserved.