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