From 7b23328d3fd30659692da453b079d843286acfff Mon Sep 17 00:00:00 2001 From: Looly Date: Thu, 27 Oct 2022 18:51:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DIoUtil.copyByNIO=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=86=99=E5=87=BA=E6=97=B6=E6=B2=A1=E6=9C=89flush?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- hutool-core/src/main/java/cn/hutool/core/io/NioUtil.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00668d017..98632f897 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ------------------------------------------------------------------------------------------------------------- -# 5.8.10.M1 (2022-10-24) +# 5.8.10.M1 (2022-10-27) ### 🐣新特性 * 【http 】 HttpResponse增加getFileNameFromDisposition方法(pr#2676@Github) @@ -13,6 +13,7 @@ * 【db 】 修复分页时order by截断问题(issue#I5X6FM@Gitee) * 【core 】 修复Partition计算size除数为0报错问题(pr#2677@Github) * 【core 】 由于对于ASCII的编码解码有缺陷,且这种BCD实现并不规范,因此BCD标记为弃用(issue#I5XEC6@Gitee) +* 【core 】 修复IoUtil.copyByNIO方法写出时没有flush的问题 ------------------------------------------------------------------------------------------------------------- # 5.8.9 (2022-10-22) diff --git a/hutool-core/src/main/java/cn/hutool/core/io/NioUtil.java b/hutool-core/src/main/java/cn/hutool/core/io/NioUtil.java index 806105051..215fd36e0 100644 --- a/hutool-core/src/main/java/cn/hutool/core/io/NioUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/io/NioUtil.java @@ -70,7 +70,9 @@ public class NioUtil { * @since 5.7.8 */ public static long copyByNIO(InputStream in, OutputStream out, int bufferSize, long count, StreamProgress streamProgress) throws IORuntimeException { - return copy(Channels.newChannel(in), Channels.newChannel(out), bufferSize, count, streamProgress); + final long copySize = copy(Channels.newChannel(in), Channels.newChannel(out), bufferSize, count, streamProgress); + IoUtil.flush(out); + return copySize; } /**