fix io bug

This commit is contained in:
Looly 2021-03-14 09:14:05 +08:00
parent 02c72c7582
commit ff23934b24
2 changed files with 8 additions and 3 deletions

View File

@ -8,6 +8,7 @@
### 新特性
* 【crypto 】 SecureUtil去除final修饰符issue#1474@Github
### Bug修复
* 【core 】 修复IoUtil.readBytes的FileInputStream中isClose参数失效问题issue#I3B7UD@Gitee
-------------------------------------------------------------------------------------------------------------

View File

@ -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();
}
/**