mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
201fe2404f
commit
772d80a8be
@ -4,7 +4,6 @@ import cn.hutool.core.codec.HexUtil;
|
|||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -194,7 +193,7 @@ 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 {
|
||||||
FileInputStream in = null;
|
InputStream in = null;
|
||||||
try {
|
try {
|
||||||
in = IoUtil.toStream(file);
|
in = IoUtil.toStream(file);
|
||||||
return getType(in, file.getName(),isExact);
|
return getType(in, file.getName(),isExact);
|
||||||
|
@ -1763,6 +1763,7 @@ public class FileUtil extends PathUtil {
|
|||||||
* @param file 文件
|
* @param file 文件
|
||||||
* @return 输入流
|
* @return 输入流
|
||||||
* @throws IORuntimeException 文件未找到
|
* @throws IORuntimeException 文件未找到
|
||||||
|
* @see IoUtil#toStream(File)
|
||||||
*/
|
*/
|
||||||
public static BufferedInputStream getInputStream(final File file) throws IORuntimeException {
|
public static BufferedInputStream getInputStream(final File file) throws IORuntimeException {
|
||||||
return IoUtil.toBuffered(IoUtil.toStream(file));
|
return IoUtil.toBuffered(IoUtil.toStream(file));
|
||||||
|
@ -23,7 +23,6 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.Flushable;
|
import java.io.Flushable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -38,6 +37,7 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.nio.CharBuffer;
|
import java.nio.CharBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -525,15 +525,15 @@ public class IoUtil extends NioUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件转为{@link FileInputStream}
|
* 文件转为{@link InputStream}
|
||||||
*
|
*
|
||||||
* @param file 文件
|
* @param file 文件
|
||||||
* @return {@link FileInputStream}
|
* @return {@link InputStream}
|
||||||
*/
|
*/
|
||||||
public static FileInputStream toStream(final File file) {
|
public static InputStream toStream(final File file) {
|
||||||
try {
|
try {
|
||||||
return new FileInputStream(file);
|
return Files.newInputStream(file.toPath());
|
||||||
} catch (final FileNotFoundException e) {
|
} catch (final IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user