mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
add test
This commit is contained in:
parent
73cf56f3a2
commit
7af3344b5e
@ -1,5 +1,7 @@
|
||||
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;
|
||||
|
||||
@ -50,9 +52,11 @@ public class FileTypeUtil {
|
||||
* @return 文件类型,未找到为{@code null}
|
||||
*/
|
||||
public static String getType(String fileStreamHexHead) {
|
||||
for (Entry<String, String> fileTypeEntry : FILE_TYPE_MAP.entrySet()) {
|
||||
if (StrUtil.startWithIgnoreCase(fileStreamHexHead, fileTypeEntry.getKey())) {
|
||||
return fileTypeEntry.getValue();
|
||||
if(MapUtil.isNotEmpty(FILE_TYPE_MAP)){
|
||||
for (final Entry<String, String> fileTypeEntry : FILE_TYPE_MAP.entrySet()) {
|
||||
if (StrUtil.startWithIgnoreCase(fileStreamHexHead, fileTypeEntry.getKey())) {
|
||||
return fileTypeEntry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
byte[] bytes = (HexUtil.decodeHex(fileStreamHexHead));
|
||||
|
@ -5,9 +5,7 @@ import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* 文件类型判断单元测试
|
||||
@ -92,4 +90,10 @@ public class FileTypeUtilTest {
|
||||
Assert.assertEquals("txt", type);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void issue3024Test() {
|
||||
String x = FileTypeUtil.getType(FileUtil.getInputStream("d:/test/TEST_WPS_DOC.doc"),true);
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user