diff --git a/CHANGELOG.md b/CHANGELOG.md index 82865b6b6..e84ddecec 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ * 【core 】 修复HexUtil.isHexNumber()对"-"的判断问题(issue#2857@Github) * 【core 】 修复FileTypeUtil判断wav后缀的录音文件类型不能匹配问题(pr#2834@Github) * 【core 】 修复FileUtil的rename在newName与原文件夹名称一样时,文件夹会被删除问题(issue#2845@Github) +* 【core 】 修复IoUtil.readBytes使用SocketInputStream读取不完整问题(issue#I6AT49@Gitee) ------------------------------------------------------------------------------------------------------------- diff --git a/hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java b/hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java index 71579ea00..924f61d97 100755 --- a/hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java @@ -471,27 +471,6 @@ public class IoUtil extends NioUtil { * @since 5.0.4 */ public static byte[] readBytes(InputStream in, boolean isClose) throws IORuntimeException { - if (in instanceof FileInputStream) { - // 文件流的长度是可预见的,此时直接读取效率更高 - final byte[] result; - try { - final int available = in.available(); - result = new byte[available]; - final int readLength = in.read(result); - if (readLength != available) { - throw new IOException(StrUtil.format("File length is [{}] but read [{}]!", available, readLength)); - } - } catch (IOException e) { - throw new IORuntimeException(e); - } finally { - if (isClose) { - close(in); - } - } - return result; - } - - // 未知bytes总量的流 return read(in, isClose).toByteArray(); }