mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix io bug
This commit is contained in:
parent
02c72c7582
commit
ff23934b24
@ -8,6 +8,7 @@
|
||||
### 新特性
|
||||
* 【crypto 】 SecureUtil去除final修饰符(issue#1474@Github)
|
||||
### Bug修复
|
||||
* 【core 】 修复IoUtil.readBytes的FileInputStream中isClose参数失效问题(issue#I3B7UD@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -448,12 +448,12 @@ public class IoUtil extends NioUtil {
|
||||
* 从流中读取bytes
|
||||
*
|
||||
* @param in {@link InputStream}
|
||||
* @param isCLose 是否关闭输入流
|
||||
* @param isClose 是否关闭输入流
|
||||
* @return bytes
|
||||
* @throws IORuntimeException IO异常
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public static byte[] readBytes(InputStream in, boolean isCLose) throws IORuntimeException {
|
||||
public static byte[] readBytes(InputStream in, boolean isClose) throws IORuntimeException {
|
||||
if (in instanceof FileInputStream) {
|
||||
// 文件流的长度是可预见的,此时直接读取效率更高
|
||||
final byte[] result;
|
||||
@ -466,12 +466,16 @@ public class IoUtil extends NioUtil {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
} finally {
|
||||
if (isClose) {
|
||||
close(in);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 未知bytes总量的流
|
||||
return read(in, isCLose).toByteArray();
|
||||
return read(in, isClose).toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user